應用ANT與YUI緊縮js的完成辦法。本站提示廣大學習愛好者:(應用ANT與YUI緊縮js的完成辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是應用ANT與YUI緊縮js的完成辦法正文
因為項目應用的js許多,為了進步體系效力,將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="創立build目次">
<mkdir dir="${build}"/>
</target>
<!-- 將多個js歸並成為一個js -->
<target name="歸並js" depends="創立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>