用到两个jar包
YUIAnt.jar 下载地址
yuicompressor-2.4.2.jar 下载地址
<property name="context" value="${basedir}\context"/> <path id="yuiClasspath"> <fileset dir="${webinf}/lib"> <include name="yuicompressor-2.4.2.jar"/> <include name="YUIAnt.jar"/> </fileset> </path>
<target name="compres-js-css" description="压缩 js css 文件"> <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask"> <classpath> <path refid="yuiClasspath"/> </classpath> </taskdef> <yuicompress linebreak="300" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${context}"> <fileset dir="${context}"> <include name="js/**/*.js" /> <include name="lib/**/*.js"/> <include name="fckeditor/**/*.js"/> <include name="css/**/*.css"/> <include name="lib/**/*.css"/> <include name="fckeditor/**/*.css"/> </fileset> </yuicompress> </target>
|
运行ant后回将原来的js和css覆盖掉
如果不想覆盖 可以设置outputfolder
阅读(1318) | 评论(0) | 转发(0) |