|
Project Information
|
IntroductionThis project provides a custom Ant task for compressing several JavaScript? files at once using YUI Compressor. At the moment it does not have support for minimising CSS files even though this is a feature of YUI Compressor. More information here: http://www.simonbuckle.com/2011/02/20/yui-compressor-ant-task/ Ant TaskThe name of the Ant task is "yuicompressor" (see the example below). It supports the following attributes:
A full description of the attributes (apart from todir) can be found on the YUI Compressor site: http://developer.yahoo.com/yui/compressor/ It also expects two child elements: fileset and mapper. These are required elements. The first specifies the list of files to compress; the second prescribes how they should be saved once minimised. ExampleHere's an example build file that looks for all the JavaScript files in the test directory and minimises them. <project name="Compressor Test" default="example" basedir=".">
<taskdef resource="yuicompressor.tasks" classpath="dist/yuicompressor-taskdef-1.0.jar"/>
<target name="example">
<yuicompressor linebreak="40" todir="${basedir}/test">
<fileset dir="${basedir}/test" includes="*.js"/>
<mapper type="glob" from="*.js" to="*-min.js"/>
</yuicompressor>
</target>
</project>Save the file as build.example.xml in the root directory of the project. To run it, type the following: ant -lib lib/yuicompressor-2.4.2.jar -f build.example.xml. The task relies on YUI Compressor so this must be specified using the -lib option. |