2

I am using ANT to deploy build in to Tomcat Server. I Want to compress the static files CSS and JS only when i deploy to the server.

any suggestion?

2 Answers 2

3

You can do something like that as part of the build (using YUI Compressor)

<target name="js.minify">
    <apply executable="java" parallel="false">
        <fileset dir="." includes="foo.js, bar.js"/>
        <arg line="-jar"/>
        <arg path="yuicompressor.jar"/>
        <srcfile/>
        <arg line="-o"/>
        <mapper type="glob" from="*.js" to="*-min.js"/>
        <targetfile/>
    </apply>
</target>

<target name="css.minify">
    <apply executable="java" parallel="false">
        <fileset dir="." includes="*.css"/>
        <arg line="-jar"/>
        <arg path="yuicompressor.jar"/>
        <arg line="--line-break 0"/>
        <srcfile/>
        <arg line="-o"/>
        <mapper type="glob" from="*.css" to="*-min.css"/>
        <targetfile/>
    </apply>
</target>

Check out this article for more info: http://www.julienlecomte.net/blog/2007/09/16/

Sign up to request clarification or add additional context in comments.

3 Comments

Is YUI Compressor is open source?
It's available under the BSD License, so yes it is open source and free to anyone (if that's what you are asking). developer.yahoo.com/yui
Just a quick intrusion—you may also want to look at code.google.com/p/jslint4java for running JSLint from ant.
1

This blog post about using YUI compressor to minify JS/CSS using Ant might help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.