使用ANT與YUI壓縮js的實現(xiàn)方法
更新時間:2013年05月17日 09:01:49 作者:
本篇文章是對使用ANT與YUI壓縮js的實現(xiàn)方法進行了詳細的分析介紹,需要的朋友參考下
由于項目使用的js很多,為了提高系統(tǒng)效率,將js做壓縮處理。
成功的對多個js進行壓縮,必須經歷下面兩步。
1.合并多個js成為一個js.
2.將和并過后的js進行壓縮處理。
使用的ant配置主要有:
<property name="root" value="WebRoot"></property>
<property name="js" value="${root}/js"></property>
<property name="map_function_js" value="${js}/mapfunc"></property>
<property name="lib" value="lib"/>
<property name="build" value="build"></property>
<property name="war" value="war"></property>
<property name="war.info" value="${war}/WEB-INF"></property>
<property name="war.lib" value="${war.info}/lib"></property>
<property name="war.classes" value="${war.info}/classes"></property>
<property name="project.name" value="zjmap"></property>
<property name="charset" value="utf-8"/>
<property name="src" value="src"/>
<target name="創(chuàng)建build目錄">
<mkdir dir="${build}"/>
</target>
<!-- 將多個js合并成為一個js -->
<target name="合并js" depends="創(chuàng)建build目錄">
<concat destfile="${build}/mapfuncall.js" encoding="${charset}" outputencoding="${charset}">
<path path="${map_function_js}/DC.js" />
<path path="${map_function_js}/stringUtil.js" />
<path path="${map_function_js}/LOCALDC.js" />
<path path="${map_function_js}/screen.js" />
<path path="${map_function_js}/wfsQuery.js" />
<path path="${map_function_js}/Map.js" />
<path path="${map_function_js}/Query.js" />
<path path="${map_function_js}/ClassificationQuery.js" />
<path path="${map_function_js}/BusQuery.js" />
<path path="${map_function_js}/RouteQuery.js" />
<path path="${map_function_js}/cursorPosition.js" />
<path path="${map_function_js}/bufferAnalysis.js" />
<path path="${map_function_js}/divCtrl.js" />
<path path="${map_function_js}/mark.js" />
<path path="${map_function_js}/overlayAnalysis.js" />
<path path="${map_function_js}/BuildQuery.js" />
<path path="${map_function_js}/PopShow.js" />
<path path="${map_function_js}/correct.js" />
<path path="${map_function_js}/style_result.js" />
<path path="${map_function_js}/style_ui.js" />
<path path="${map_function_js}/Catalog.js" />
<path path="${map_function_js}/scenario.js" />
<path path="${map_function_js}/wfs.js" />
<path path="${map_function_js}/Uuid.js" />
<path path="${map_function_js}/Gps.js" />
<path path="${map_function_js}/typhoon.js" />
<path path="${map_function_js}/Monitor.js" />
<path path="${map_function_js}/RainWater.js" />
<path path="${map_function_js}/Approval.js" />
<path path="${map_function_js}/statistics.js" />
<path path="${map_function_js}/statisticsNew.js" />
<path path="${map_function_js}/OTileCacheCustom.js" />
<path path="${map_function_js}/BQTool.js" />
<path path="${map_function_js}/CityPositionQuery.js" />
<path path="${map_function_js}/IFieldService.js" />
<path path="${map_function_js}/SpecialQuery.js" />
</concat>
<replaceregexp match="@DEBUG@" replace="" flags="g" byline="true" file="${build}/mapfuncall.js" encoding="${charset}" />
</target>
<!-- 使用雅虎UI進行js壓縮 -->
<target name="開始壓縮" depends="合并js">
<!-- 使用雅虎UI壓縮 mapfuncall.js -->
<antcall target="壓縮mapfuncall.js"></antcall>
<!-- 使用雅虎UI壓縮 dataedit.js -->
<antcall target="壓縮dataedit.js"></antcall>
<!-- 使用雅虎UI壓縮 ISuggest.js -->
<antcall target="壓縮ISuggest.js"></antcall>
<!-- 復制壓縮后的js文件 -->
<antcall target="復制壓縮js文件"></antcall>
</target>
<target name="壓縮mapfuncall.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/mapfuncall.js -o ${build}/mapfuncall-min.js"/>
</java>
</target>
<target name="壓縮dataedit.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/dataedit.js -o ${build}/dataedit-min.js"/>
</java>
</target>
<target name="壓縮ISuggest.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/ISuggest.js -o ${build}/ISuggest-min.js"/>
</java>
</target>
<target name="清除build目錄" depends="開始壓縮">
<delete dir="${build}"/>
</target>
<target name="復制壓縮js文件">
<copy todir="${map_function_js}">
<fileset dir="${build}">
<include name="**.js"/>
</fileset>
</copy>
</target>
成功的對多個js進行壓縮,必須經歷下面兩步。
1.合并多個js成為一個js.
2.將和并過后的js進行壓縮處理。
使用的ant配置主要有:
復制代碼 代碼如下:
<property name="root" value="WebRoot"></property>
<property name="js" value="${root}/js"></property>
<property name="map_function_js" value="${js}/mapfunc"></property>
<property name="lib" value="lib"/>
<property name="build" value="build"></property>
<property name="war" value="war"></property>
<property name="war.info" value="${war}/WEB-INF"></property>
<property name="war.lib" value="${war.info}/lib"></property>
<property name="war.classes" value="${war.info}/classes"></property>
<property name="project.name" value="zjmap"></property>
<property name="charset" value="utf-8"/>
<property name="src" value="src"/>
<target name="創(chuàng)建build目錄">
<mkdir dir="${build}"/>
</target>
復制代碼 代碼如下:
<!-- 將多個js合并成為一個js -->
<target name="合并js" depends="創(chuàng)建build目錄">
<concat destfile="${build}/mapfuncall.js" encoding="${charset}" outputencoding="${charset}">
<path path="${map_function_js}/DC.js" />
<path path="${map_function_js}/stringUtil.js" />
<path path="${map_function_js}/LOCALDC.js" />
<path path="${map_function_js}/screen.js" />
<path path="${map_function_js}/wfsQuery.js" />
<path path="${map_function_js}/Map.js" />
<path path="${map_function_js}/Query.js" />
<path path="${map_function_js}/ClassificationQuery.js" />
<path path="${map_function_js}/BusQuery.js" />
<path path="${map_function_js}/RouteQuery.js" />
<path path="${map_function_js}/cursorPosition.js" />
<path path="${map_function_js}/bufferAnalysis.js" />
<path path="${map_function_js}/divCtrl.js" />
<path path="${map_function_js}/mark.js" />
<path path="${map_function_js}/overlayAnalysis.js" />
<path path="${map_function_js}/BuildQuery.js" />
<path path="${map_function_js}/PopShow.js" />
<path path="${map_function_js}/correct.js" />
<path path="${map_function_js}/style_result.js" />
<path path="${map_function_js}/style_ui.js" />
<path path="${map_function_js}/Catalog.js" />
<path path="${map_function_js}/scenario.js" />
<path path="${map_function_js}/wfs.js" />
<path path="${map_function_js}/Uuid.js" />
<path path="${map_function_js}/Gps.js" />
<path path="${map_function_js}/typhoon.js" />
<path path="${map_function_js}/Monitor.js" />
<path path="${map_function_js}/RainWater.js" />
<path path="${map_function_js}/Approval.js" />
<path path="${map_function_js}/statistics.js" />
<path path="${map_function_js}/statisticsNew.js" />
<path path="${map_function_js}/OTileCacheCustom.js" />
<path path="${map_function_js}/BQTool.js" />
<path path="${map_function_js}/CityPositionQuery.js" />
<path path="${map_function_js}/IFieldService.js" />
<path path="${map_function_js}/SpecialQuery.js" />
</concat>
<replaceregexp match="@DEBUG@" replace="" flags="g" byline="true" file="${build}/mapfuncall.js" encoding="${charset}" />
</target>
<!-- 使用雅虎UI進行js壓縮 -->
<target name="開始壓縮" depends="合并js">
<!-- 使用雅虎UI壓縮 mapfuncall.js -->
<antcall target="壓縮mapfuncall.js"></antcall>
<!-- 使用雅虎UI壓縮 dataedit.js -->
<antcall target="壓縮dataedit.js"></antcall>
<!-- 使用雅虎UI壓縮 ISuggest.js -->
<antcall target="壓縮ISuggest.js"></antcall>
<!-- 復制壓縮后的js文件 -->
<antcall target="復制壓縮js文件"></antcall>
</target>
<target name="壓縮mapfuncall.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/mapfuncall.js -o ${build}/mapfuncall-min.js"/>
</java>
</target>
<target name="壓縮dataedit.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/dataedit.js -o ${build}/dataedit-min.js"/>
</java>
</target>
<target name="壓縮ISuggest.js">
<java jar="${lib}/yui/yuicompressor-2.4.6.jar" fork="true">
<arg line="--type js --charset utf-8 ${map_function_js}/ISuggest.js -o ${build}/ISuggest-min.js"/>
</java>
</target>
<target name="清除build目錄" depends="開始壓縮">
<delete dir="${build}"/>
</target>
<target name="復制壓縮js文件">
<copy todir="${map_function_js}">
<fileset dir="${build}">
<include name="**.js"/>
</fileset>
</copy>
</target>
相關文章
Java實戰(zhàn)之課程在線學習系統(tǒng)的實現(xiàn)
本文將采用SpringBoot+Spring+Mybatis+Thyeleaf實現(xiàn)一個課程在線學習系統(tǒng),采用SpringBoot框架實現(xiàn)?前臺模板用的thymeleaf數據庫層采用mybatis框架注解模式,感興趣的可以了解一下2022-04-04關于java.lang.NumberFormatException: null的問題及解決
這篇文章主要介紹了關于java.lang.NumberFormatException: null的問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-09-09JAVA基于靜態(tài)數組實現(xiàn)棧的基本原理與用法詳解
這篇文章主要介紹了JAVA基于靜態(tài)數組實現(xiàn)棧的基本原理與用法,結合實例形式詳細分析了JAVA基于靜態(tài)數組實現(xiàn)棧相關原理、用法與操作注意事項,需要的朋友可以參考下2020-03-03深入淺出MyBatis中映射文件和實體類的關聯(lián)性
這篇文章主要介紹了MyBatis中映射文件和實體類的關聯(lián)性的相關知識,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09