First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

As I anticipated yesterday, I implemented the YUI JS compressor inside Subtext's build process, and since it took me a while to understand how to specify the arguments for the NAnt <exec> task I wanted to share the snippet of the build file I created:

<target name="JavaScript.minify">
    <echo message="${filename}" />
    <exec program="java" workingdir="${YUICompressor.dir}">
        <arg value="-jar" />
        <arg value="yuicompressor.jar" />
        <arg value="-o" />
        <arg value="${filename}.min" />
        <arg value="${filename}" />
    <move file="${filename}.min" tofile="${filename}" overwrite="true" />

This target takes the JavaScript file, compress it with the default settings, and overwrite the original file with the compressed one.

Below are the lines used to call the javascript.minify target:

<property name="filename" value="C:\myfolder\common.js"/>
<call target="javascript.minify" />

The filename property must be an absolute path, or relative to the folder where the file yuicompressor.jar is located.

posted on Wednesday, August 22, 2007 2:11 PM
Comments have been closed on this topic.