使用YUI+Ant 實現(xiàn)JS CSS壓縮
今天研究了一下YUI yahoo開源框架,感覺很猛啊。
于是乎我做了一個YUI的ant實現(xiàn),網(wǎng)上好多關于bat的實現(xiàn),我就另辟蹊徑,出個關于這個的ant實現(xiàn),嘿嘿獨一無二的文章,如果轉載的話,其注明作者和網(wǎng)站
copyright:Mr.chen
好了具體操作如下:
官網(wǎng):
yuicompressor-2.4.6.jar 下載地址 http://yuilibrary.com/downloads/#yuicompressor
YUIAnt.jar 下載地址 http://www.ubik-ingenierie.com/miscellanous/YUIAnt/
具體的相關代碼如下:
#css work dir commonCss.dir = css #js work dir commonJs.dir = js #build temp dir output.temp.dir = build #output files in the directory output.dir = ${output.temp.dir}_output #environment needs lib liblib = lib <?xml version="1.0" encoding="UTF-8"?> <project name="Compress CSS-JS" default="compress" basedir="."> <property file="bulid.properties" /> <path id="yuiClasspath"> <fileset dir="${lib}"> <include name="*.*" /> </fileset> </path> <!-- #######################Init the environment of the tool ##########################--> <target name="init"> <echo message="begin to init the init" /> <echo message="delete all reference files." /> <delete dir="${output.dir}" /> <echo message="delete end" /> <echo message="make the reference files." /> <mkdir dir="${output.dir}" /> <mkdir dir="${output.temp.dir}" /> <echo message="make end." /> </target> <!-- #######################Combine the css files ##########################--> <target name="combinecss" depends="init" description="Combine common css files"> <echo message="begin to combine the css files to one file." /> <concat destfile="${output.temp.dir}/combined_css.css" encoding="UTF-8" append="false"> <fileset dir="${commonCss.dir}"> <include name="*.css" /> </fileset> </concat> <echo message="combine end." /> </target> <!-- #######################Combine the js files ##########################--> <target name="combinejs"> <echo message="begin to combine the js files to one file." /> <concat destfile="${output.temp.dir}/all_source.js" encoding="utf-8" append="false"> <fileset dir="${commonJs.dir}"> <include name="*.js" /> </fileset> </concat> <echo message="combine end." /> </target> <!-- #######################Compress the js and css files ##########################--> <target name="compress" depends="combinecss,combinejs" description="Compress"> <echo message="begin to compress the css file." /> <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask"> <classpath> <path refid="yuiClasspath" /> </classpath> </taskdef> <!-- first method compress the css files --> <yuicompress linebreak="10000000" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${output.dir}"> <fileset dir="${output.temp.dir}"> <include name="*.css" /> </fileset> </yuicompress> <echo message ="compress the css end." /> <!-- second method compress the js files--> <echo message ="begin to compress the js file." /> <apply executable="java" parallel="false" failonerror="true"> <fileset dir="${output.temp.dir}" includes="all_source.js" /> <arg line="-jar" /> <arg path="${lib}/yuicompressor-2.4.6.jar" /> <arg line="--charset utf-8" /> <arg line="-o ${output.dir}/combined_js.js" /> <srcfile /> </apply> <echo message ="compress the js end." /> <delete dir="${output.temp.dir}" /> </target> </project> @echo off echo ################################################ echo ##########Tool Compress the js and css########## echo ################################################ echo Please make sure your css and js in the css'directory and js'directory. echo If sure,please enter any button to continue the tool. pause call ant -buildfile compress.xml compress>build.log echo compress end pause
相關的文件我提供下載,感覺好的,就留言吧
相關文章
PHP下使用mysqli的函數(shù)連接mysql出現(xiàn)warning: mysqli::real_connect(): (hy
這篇文章主要介紹了PHP下使用mysqli的函數(shù)連接mysql出現(xiàn)warning: mysqli::real_connect(): (hy000/1040): ...的相關資料,需要的朋友可以參考下2016-02-02php設計模式之狀態(tài)模式實例分析【星際爭霸游戲案例】
這篇文章主要介紹了php設計模式之狀態(tài)模式,結合星際爭霸游戲案例形式分析了php狀態(tài)模式相關原理、使用技巧與注意事項,需要的朋友可以參考下2020-03-03Laravel事件系統(tǒng)實現(xiàn)瀏覽量的統(tǒng)計
Laravel的事件系統(tǒng)提供了一種簡單而強大的方式來實現(xiàn)瀏覽量的統(tǒng)計,通過創(chuàng)建瀏覽事件和事件監(jiān)聽器,以及在合適的地方觸發(fā)事件,我們可以輕松地實現(xiàn)網(wǎng)頁瀏覽量的統(tǒng)計功能,本文將介紹如何使用Laravel的事件系統(tǒng)來實現(xiàn)瀏覽量的統(tǒng)計2024-03-03PHP實現(xiàn)RSA加解密算法示例(生成密鑰位數(shù)為1024位的方法)
下面小編就為大家分享一篇PHP實現(xiàn)RSA加解密算法示例(生成密鑰位數(shù)為1024位的方法),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03使用laravel和ECharts實現(xiàn)折線圖效果的例子
今天小編就為大家分享一篇使用laravel和ECharts實現(xiàn)折線圖效果的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10