Sunday, February 3, 2008

Building Javascript with Ant and YUI Compressor

I recently spent some time wrestling with Ant and YUI Compressor.
What I wanted to do was take a group of js files and run them through the compressor, and then append them into a single file in a specific order.

Here is what I did:

<apply executable="java" parallel="false">
<filelist dir="WebContent/scripts">
<file name="myFile1.js" />
<file name="myFile2.js.js" />
<file name="dir1/dir2/myFile3.js" />
</filelist>

<arg line="-jar"/>
<arg path="${yuicompressor.jar.file}"/>
<redirector output="../build/WebContent/scripts/main.js" append="true">
</redirector>
</apply>


I hope this helps.

No comments: