压缩css和js文件
通过以下脚本可以压缩css和js脚本
<?xml version="1.0" encoding="UTF-8"?>
<!-- 对指定目录下的所有js进行压缩,放入指定位置 -->
<project name="jsbuild" default="compres-js-css">
??? <property file="build.properties" />
??? <path id="yuiClasspath">
??? ??? <fileset dir="lib">
??? ??? ??? <include name="yuicompressor-2.4.2.jar" />
??? ??? ??? <include name="rhino-1.6R7.jar" />
??? ??? ??? <include name="plexus-utils-2.0.5.jar" />
??? ??? ??? <include name="YUIAnt.jar" />
??? ??? </fileset>
??? </path>
??? <target name="compres-js-css" description="压缩 js css 文件">
??? ??? <delete dir="${output.dir}" failonerror="false" />
??? ??? <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask">
??? ??? ??? <classpath>
??? ??? ??? ??? <path refid="yuiClasspath" />
??? ??? ??? </classpath>
??? ??? </taskdef>
??? ??? <taskdef name="aggregation" classname="com.yahoo.platform.yui.compressor.AggregationTask">
??? ??? ??? <classpath>
??? ??? ??? ??? <path refid="yuiClasspath" />
??? ??? ??? </classpath>
??? ??? </taskdef>
??? ??? <yuicompress linebreak="3000" warn="false" munge="yes" preserveallsemicolons="false" preserveStringLitterals="false" charset="UTF-8" outputfolder="${output.dir}">
??? ??? ??? <fileset dir="${source.dir}">
??? ??? ??? ??? <include name="**/*.js" />
??? ??? ??? ??? <include name="**/*.css" />
??? ??? ??? </fileset>
??? ??? </yuicompress>
??? </target>
</project>