PDA

View Full Version : Tweaked 'Copy source to the following directory'



watrboy00
27 Mar 2009, 11:56 PM
So today while I was at work I got to thinking that its a takes a lot of effort to run all these separate JS Builder projects just to generate a complete Ext JS build with the required JavaScript and accompanying resources as well as a build of my website's JavaScript and accompanying resources.

Now I know what you are all thinking....wow you must be lazy a whole whopping 2 clicks per jsb project?!?! Well I am a programmer and I am very lazy! :D

So in my nature to be completely lazy as possible I decided to tackle this and add a new attribute for the jsb source.

Attribute: 'output'

Example:

<file name="YOUR SOURCE FILE" output="true" path="YOUR OUTPUT PATH RELATIVE TO THE BUILD SETTINGS OUTPUT DIRECTORY" />

I add this attribute in because the 'Copy source to the following directory' build settings didn't quite work the way I wanted it to. Obviously I use JS Builder to minify my css and js source to move it to a production enviorment but it would be nice to only copy the needed files over to the output directory instead of all them (IE all the images used in the css but not the source css or js). Remember we are combinding compressing multiple files down to just one. I don't need all the files that were used in building the minified file...just the end result.

Having this new attribute allows you to output images to the output directory just like a target would but without having to specify a build target. Now instead of having a JSB for CSS, Images, and JavaScript you can have just on JSB that does it all.

So now in my production environment I have the following directory sturcture pre-build...

.
..css
..images
..resources
..scripts

in which case my jsb project takes the files from the css, images, and scripts folders and outputs them to the resources folder. On post build I just do a delete command of the css, images, and scripts folders and I am left with the resources folder only containing just the minified css & js as well as the required images for them. No cleanup of unneeded files on the server when I am all done.

I've attached two zip files...one a setup file for the new exe of JS Builder and a sample JSB project showing usage. Just drop an ext js source in a folder named 'ext' and place the sample jsb in the same root folder as the ext and build on.

I can post the solution as well if anyone would like.

Enjoy!

mjlecomte
28 Mar 2009, 12:09 AM
What's different here than just making a batch file to do what you want?

watrboy00
28 Mar 2009, 12:35 AM
Had a batch file...just was two files I had to maintain over just one. If I am using JS Builder already then there is no need for me to make a bat file just to copy files.

mjlecomte
28 Mar 2009, 12:40 AM
6 or 1/2 dozen maybe, yeah just maintain one file, but which file, a jsb file or a bat file. Seems more universally customizable to impose your will in a bat file. I have the bat file autogenerate docs, clean up some directories, etc. Granted your suggestion affords the option to do either.

watrboy00
28 Mar 2009, 12:49 AM
On my latest team we are upgrading to Team Server which will automate really a lot of this for me on its own in which case I won't need to have bat files and what not.

Granted to your point a bat file provides more flexibility in what you can actually do but for what I 'currently' deal with the only un-automated process is copying images from a one directory to another.

Plus modifying the source was like maybe 10 lines of code to add the flexibility and really only took a couple minutes once I figure out where everything was in the solution.

Each has their use...people can use as they see fit. Just a minor tweak. ;)

mjlecomte
28 Mar 2009, 4:30 AM
You might consider either updating the wiki entry or pointing a link back here for interested parties.
http://extjs.com/learn/Tutorial:Building_Ext_From_Source#Script_Automation_2

Really, I think all wiki entries should have a linked forum post dedicated to discussing a particular wiki entry anyway.

watrboy00
13 Apr 2009, 8:41 AM
Yea I will look into updating the wiki. Down at the conference right now so if I get some time I will do it then.

mjlecomte
13 Apr 2009, 3:06 PM
Yea I will look into updating the wiki. Down at the conference right now so if I get some time I will do it then.

Gasp. Surely you could find something more entertaining to do while at the conference!!!!

watrboy00
16 Apr 2009, 5:56 AM
Yea....haven't spent much time in the room. Laptop has been off pretty much the entire conference. Other more entertaining things have come up! :>