GithubHelp home page GithubHelp logo

yui-compressor-ant-task's Introduction

Introduction

This project provides a custom Ant task for compressing JavaScript and CSS files using YUI Compressor.

More information here: http://www.simonbuckle.com/2011/02/20/yui-compressor-ant-task/

Ant Task

The name of the Ant task is "yuicompressor" (see the example below). It supports the following attributes:

Attribute Required Default Value
linebreak No -1
munge No true
preserveAllSemiColons No false
disableOptimizations No false
verbose No false
todir Yes N/A

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.

To build it run: ant package.

Example

Here's an example build file that looks for all the JavaScript files in the test directory and minimises them:

    <taskdef resource="yuicompressor.tasks" classpath="dist/yuicompressor-taskdef-1.0.jar"/>
    
    <target name="example">
            <yuicompressor linebreak="40" todir="/var/www">
                    <fileset dir="${basedir}/test" includes="*.js"/>
                    <mapper type="glob" from="*.js" to="*-min.js"/>
            </yuicompressor>
    </target>

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.)

Here's another example that compresses both CSS and JavaScript files:

    <taskdef resource="yuicompressor.tasks" classpath="dist/yuicompressor-taskdef-1.0.jar"/>
    
    <target name="example">
            <yuicompressor linebreak="40" todir="/var/www">
                    <fileset dir="${basedir}/test" includes="*.css,*.js"/>
                    <mapper>
                          <globmapper from="*.css" to="*-min.css"/>
                          <globmapper from="*.js" to="*-min.js"/>
                    </mapper>
            </yuicompressor>
    </target>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.