PDA

View Full Version : ant task for minification and combination?


ilazarte
02-18-2007, 12:55 PM
There's various code snippets here and there, but I'm wondering knows if one that has this already or knows of a source...

Animal
02-18-2007, 01:39 PM
Remembering that there are dependencies, you have to concatenate in the correct order. this is how I do it:



<concat destfile="${basedir}/WebRoot/WEB-INF/classes/Aspicio-debug.js" fixlastline="yes" append="no">
<filelist
dir="${basedir}/WebRoot/js"
files="yahoo.js,event.js,dom.js,logger.js,connection.js,animation.js,
dragdrop.js,treeview.js,container.js,menu.js,
yui-ext.js,
fcl.js,ListManager.js,InputField.js"/>
</concat>
<concat destfile="${basedir}/WebRoot/WEB-INF/classes/Aspicio-debug.js" fixlastline="yes" append="yes">
<fileset dir="${basedir}/WebRoot/js"
includes="*.js"
excludes="yahoo.js,event.js,dom.js,logger.js,connection.js,animation.js,
dragdrop.js,treeview.js,container.js,menu.js,
yui-ext.js,
fcl.js,ListManager.js,InputField.js"/>
</concat>


<java fork="true" jar="${basedir}/jars/custom_rhino.jar"
output="${basedir}/WebRoot/WEB-INF/classes/Aspicio.js">
<jvmarg line="-Xmn100M -Xms500M -Xmx500M"/>
<arg line=" -opt -1 -c ${basedir}/WebRoot/WEB-INF/classes/Aspicio-debug.js"/>
</java>


First I concat the files on which others depend in the correct order.

Then I add all the others allowing Ant to use directory order. I explicitly exclude those already added.

Then I use the Dojo minifier.

As it happens I also serve the JS files gzipped, but that's another story...