使用YUI+Ant 实现JS CSS压缩

王朝学院·作者佚名  2016-05-24
窄屏简体版  字體: 小  |  中  |  大  |  超大  

使用YUI+Ant 实现JS CSS压缩今天研究了一下YUI yahoo开源框架,感觉很猛啊。

于是乎我做了一个YUI的ant实现,网上好多关于bat的实现,我就另辟蹊径,出个关于这个的ant实现,嘿嘿独一无二的文章,如果转载的话,其注明作者和网站

copyright:Mr.chen

好了具体操作如下:

官网:

yuicomPRessor-2.4.6.jar 下载地址 http://yuilibrary.com/downloads/#yuicompressor

YUIAnt.jar 下载地址 http://www.ubik-ingenierie.com/miscellanous/YUIAnt/

具体的相关代码如下:

xml代码#cssworkdircommonCss.dir=css#jsworkdircommonJs.dir=js#buildtempdiroutput.temp.dir=build#outputfilesinthedirectoryoutput.dir=${output.temp.dir}_output#environmentneedslibliblib=libBuild.xml代码<?xmlversion="1.0"encoding="UTF-8"?><projectname="CompressCSS-JS"default="compress"basedir="."><propertyfile="bulid.properties"/><pathid="yuiClasspath"><filesetdir="${lib}"><includename="*.*"/></fileset></path><!--#######################Inittheenvironmentofthetool##########################--><targetname="init"><echomessage="begintoinittheinit"/><echomessage="deleteallreferencefiles."/><deletedir="${output.dir}"/><echomessage="deleteend"/><echomessage="makethereferencefiles."/><mkdirdir="${output.dir}"/><mkdirdir="${output.temp.dir}"/><echomessage="makeend."/></target><!--#######################Combinethecssfiles##########################--><targetname="combinecss"depends="init"description="Combinecommoncssfiles"><echomessage="begintocombinethecssfilestoonefile."/><concatdestfile="${output.temp.dir}/combined_css.css"encoding="UTF-8"append="false"><filesetdir="${commonCss.dir}"><includename="*.css"/></fileset></concat><echomessage="combineend."/></target><!--#######################Combinethejsfiles##########################--><targetname="combinejs"><echomessage="begintocombinethejsfilestoonefile."/><concatdestfile="${output.temp.dir}/all_source.js"encoding="utf-8"append="false"><filesetdir="${commonJs.dir}"><includename="*.js"/></fileset></concat><echomessage="combineend."/></target><!--#######################Compressthejsandcssfiles##########################--><targetname="compress"depends="combinecss,combinejs"description="Compress"><echomessage="begintocompressthecssfile."/><taskdefname="yuicompress"classname="com.yahoo.platform.yui.compressor.YUICompressTask"><classpath><pathrefid="yuiClasspath"/></classpath></taskdef><!--firstmethodcompressthecssfiles--><yuicompresslinebreak="10000000"warn="false"munge="yes"preserveallsemicolons="true"outputfolder="${output.dir}"><filesetdir="${output.temp.dir}"><includename="*.css"/></fileset></yuicompress><echomessage="compressthecssend."/><!--secondmethodcompressthejsfiles--><echomessage="begintocompressthejsfile."/><applyexecutable="java"parallel="false"failonerror="true"><filesetdir="${output.temp.dir}"includes="all_source.js"/><argline="-jar"/><argpath="${lib}/yuicompressor-2.4.6.jar"/><argline="--charsetutf-8"/><argline="-o${output.dir}/combined_js.js"/><srcfile/></apply><echomessage="compressthejsend."/><deletedir="${output.temp.dir}"/></target></project>Xml代码@echooffecho################################################echo##########ToolCompressthejsandcss##########echo################################################echoPleasemakesureyourcssandjsinthecss'directoryandjs'directory.echoIfsure,pleaseenteranybuttontocontinuethetool.pausecallant-buildfilecompress.xmlcompress>build.logechocompressendpause相关的文件我提供下载,感觉好的,就留言吧

YUICompressor.zip(1.5 MB)

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航