使用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)文章
spring聲明式事務(wù)@Transactional開(kāi)發(fā)常犯的幾個(gè)錯(cuò)誤及最新解決方案
使用聲明式事務(wù)@Transactional進(jìn)行事務(wù)一致性的管理,在開(kāi)發(fā)過(guò)程中,發(fā)現(xiàn)很多開(kāi)發(fā)同學(xué)都用錯(cuò)了spring聲明式事務(wù)@Transactional或使用不規(guī)范,導(dǎo)致出現(xiàn)各種事務(wù)問(wèn)題,這篇文章主要介紹了spring聲明式事務(wù)@Transactional開(kāi)發(fā)常犯的幾個(gè)錯(cuò)誤及解決辦法,需要的朋友可以參考下2024-02-02
Java與Scala創(chuàng)建List與Map的實(shí)現(xiàn)方式
這篇文章主要介紹了Java與Scala創(chuàng)建List與Map的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-10-10
java 解決異常 2 字節(jié)的 UTF-8 序列的字節(jié)2 無(wú)效的問(wèn)題
這篇文章主要介紹了java 解決異常 2 字節(jié)的 UTF-8 序列的字節(jié) 2 無(wú)效的問(wèn)題的相關(guān)資料,需要的朋友可以參考下2016-12-12
springmvc實(shí)現(xiàn)跨服務(wù)器文件上傳功能
這篇文章主要為大家詳細(xì)介紹了springmvc實(shí)現(xiàn)跨服務(wù)器文件上傳功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-08-08
Springboot使用Redis中ZSetOperations實(shí)現(xiàn)博客訪問(wèn)量
在日常的網(wǎng)站使用中,經(jīng)常會(huì)碰到頁(yè)面的訪問(wèn)量,本文主要介紹了Springboot使用Redis中ZSetOperations實(shí)現(xiàn)博客訪問(wèn)量,具有一定的參考價(jià)值,感興趣的可以了解一下2024-01-01
JAVA基本類(lèi)型包裝類(lèi) BigDecimal BigInteger 的使用
Java 中預(yù)定義了八種基本數(shù)據(jù)類(lèi)型,包括:byte,int,long,double,float,boolean,char,short,接下來(lái)文章小編將向大家介紹其中幾個(gè)類(lèi)型的內(nèi)容,需要的朋友可以參考下文章2021-09-09
spring boot項(xiàng)目導(dǎo)入依賴(lài)后代碼報(bào)錯(cuò)問(wèn)題的解決方法
這篇文章主要給大家介紹了關(guān)于spring boot項(xiàng)目導(dǎo)入依賴(lài)后代碼報(bào)錯(cuò)問(wèn)題的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用spring Boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08

