Minifying JS/CSS
From UbikWiki
(Difference between revisions)
(→Download the ANT Jar [http://www.ubik-ingenierie.com/miscellanous/YUIAnt/ YUIant.jar](open path and download)) |
(→Download this Eclipse project [http://www.ubik-ingenierie.com/miscellanous/YUIAnt/ YUIant.zip]) |
||
Line 1: |
Line 1: | ||
== Configuration from Project == | == Configuration from Project == | ||
- | === Download this Eclipse project [http://www.ubik-ingenierie.com/miscellanous/YUIAnt/ YUIant.zip] === | + | === Download this Eclipse project [http://www.ubik-ingenierie.com/miscellanous/YUIAnt/ YUIant.zip] (open path then download)=== |
+ | |||
=== Set 2 environment variables: === | === Set 2 environment variables: === | ||
* ANT_HOME | * ANT_HOME |
Revision as of 22:22, 19 November 2007
Contents |
Configuration from Project
Download this Eclipse project YUIant.zip (open path then download)
Set 2 environment variables:
- ANT_HOME
- YUI_COMPRESSOR_HOME (must point to YUICompressor folder)
Run target jar to generate the YUIAnt.jar file in dist folder
Put your JS/CSS files to minify in js folder
Run target minify, minified files will be generated in jsmin
Configuration using YUIAnt.jar
Download the ANT Jar YUIant.jar(open path then download)
Set 1 environment variable:
- YUI_COMPRESSOR_HOME (must point to YUICompressor folder)
Put your JS/CSS files to minify in js folder
Add this ANT target to your build file
You will certainly have to modify the path to js and jsmin folders:
<target name="minify" depends="init" description="Minifiy a set of files"> <available file="${dist.dir}/YUIAnt.jar" property="YUIANT_AVAILABLE" /> <fail unless="YUIANT_AVAILABLE" message="Run jar target to generate the required task"/> <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask"> <classpath> <pathelement path="${env.YUI_COMPRESSOR_HOME}/build/yuicompressor-2.2.5.jar" /> <pathelement path="${dist.dir}/YUIAnt.jar" /> </classpath> </taskdef> <mkdir dir="${jsmin.dir}" /> <yuicompress linebreak="300" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${jsmin.dir}"> <fileset dir="${js.dir}" > <include name="**/*.js" /> <include name="**/*.css" /> </fileset> </yuicompress> </target>