使用ANT與YUI壓縮js的實(shí)現(xiàn)方法
成功的對(duì)多個(gè)js進(jìn)行壓縮,必須經(jīng)歷下面兩步。
1.合并多個(gè)js成為一個(gè)js.
2.將和并過(guò)后的js進(jìn)行壓縮處理。
使用的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>
<!-- 將多個(gè)js合并成為一個(gè)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進(jìn)行js壓縮 -->
<target name="開(kāi)始?jí)嚎s" 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>
<!-- 復(fù)制壓縮后的js文件 -->
<antcall target="復(fù)制壓縮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="開(kāi)始?jí)嚎s">
<delete dir="${build}"/>
</target>
<target name="復(fù)制壓縮js文件">
<copy todir="${map_function_js}">
<fileset dir="${build}">
<include name="**.js"/>
</fileset>
</copy>
</target>
相關(guān)文章
淺談Java多線程編程中Boolean常量的同步問(wèn)題
這篇文章主要介紹了淺談Java多線程編程中Boolean常量的同步問(wèn)題,主要針對(duì)線程之間同步了不同的布爾對(duì)象的問(wèn)題,需要的朋友可以參考下2015-10-10詳解高性能緩存Caffeine原理及實(shí)戰(zhàn)
Caffeine是基于Java 8開(kāi)發(fā)的,提供了近乎最佳命中率的高性能本地緩存組件,Spring5開(kāi)始不再支持Guava Cache,改為使用Caffeine。Caffeine提供的內(nèi)存緩存使用參考Google guava的API2021-06-06java生成excel并導(dǎo)出到對(duì)應(yīng)位置的方式
這篇文章主要介紹了java生成excel并導(dǎo)出到對(duì)應(yīng)位置的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-01-01Java實(shí)戰(zhàn)之課程在線學(xué)習(xí)系統(tǒng)的實(shí)現(xiàn)
本文將采用SpringBoot+Spring+Mybatis+Thyeleaf實(shí)現(xiàn)一個(gè)課程在線學(xué)習(xí)系統(tǒng),采用SpringBoot框架實(shí)現(xiàn)?前臺(tái)模板用的thymeleaf數(shù)據(jù)庫(kù)層采用mybatis框架注解模式,感興趣的可以了解一下2022-04-04關(guān)于java.lang.NumberFormatException: null的問(wèn)題及解決
這篇文章主要介紹了關(guān)于java.lang.NumberFormatException: null的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09JAVA基于靜態(tài)數(shù)組實(shí)現(xiàn)棧的基本原理與用法詳解
這篇文章主要介紹了JAVA基于靜態(tài)數(shù)組實(shí)現(xiàn)棧的基本原理與用法,結(jié)合實(shí)例形式詳細(xì)分析了JAVA基于靜態(tài)數(shù)組實(shí)現(xiàn)棧相關(guān)原理、用法與操作注意事項(xiàng),需要的朋友可以參考下2020-03-03深入淺出MyBatis中映射文件和實(shí)體類的關(guān)聯(lián)性
這篇文章主要介紹了MyBatis中映射文件和實(shí)體類的關(guān)聯(lián)性的相關(guān)知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09java基礎(chǔ)之 Arrays.toString()方法詳解
這篇文章主要介紹了java基礎(chǔ)之 Arrays.toString()方法詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-02-02