《PHP應(yīng)用:使用YUI+Ant 實(shí)現(xiàn)JS CSS壓縮》要點(diǎn):
本文介紹了PHP應(yīng)用:使用YUI+Ant 實(shí)現(xiàn)JS CSS壓縮,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
PHP應(yīng)用本日研究了一下YUI yahoo開源框架,感覺很猛啊.
PHP應(yīng)用于是乎我做了一個(gè)YUI的ant實(shí)現(xiàn),網(wǎng)上好多關(guān)于bat的實(shí)現(xiàn),我就另辟蹊徑,出個(gè)關(guān)于這個(gè)的ant實(shí)現(xiàn),嘿嘿舉世無雙的文章,如果轉(zhuǎn)載的話,其注明作者和網(wǎng)站
PHP利用copyright:Mr.chen
PHP利用好了具體操作如下:
PHP利用官網(wǎng):
PHP利用yuicompressor-2.4.6.jar 下載地址 http://yuilibrary.com/downloads/#yuicompressor
PHP利用YUIAnt.jar 下載地址 http://www.ubik-ingenierie.com/miscellanous/YUIAnt/
PHP利用具體的相關(guān)代碼如下:
PHP利用
#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利用?
?相關(guān)的文件我提供下載,感覺好的,就留言吧
《PHP應(yīng)用:使用YUI+Ant 實(shí)現(xiàn)JS CSS壓縮》是否對(duì)您有啟發(fā),歡迎查看更多與《PHP應(yīng)用:使用YUI+Ant 實(shí)現(xiàn)JS CSS壓縮》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/14763.html