ant script for css/js compression

本文介绍了一个名为 YakBootstrap 的项目的构建过程,该过程包括 JavaScript 和 CSS 文件的压缩及合并,同时更新了 HTML 文件中的资源引用。通过 Ant 脚本实现了整个构建流程的自动化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<?xml version="1.0" encoding="UTF-8"?>
<project name="yakbootstrap" default="yakbootstrap" basedir=".">
<property name="yuicompressor.path" location="D:\tool\yuicompressor.jar"/>
<property name="closure.path" location="D:\tool\compiler.jar"/>
<property name="js.files" value="yakbootstrap.yakautocomplete.js, yakbootstrap.yaktag.js, yakbootstrap.yakpassportsearch.js,
yakbootstrap.yakdatepicker.js, yakbootstrap.yaktimepicker.js, yakbootstrap.yakdatetimepicker.js,
konami.js, run.js"/>
<property name="yak.path" value="resources\yakbootstrap\" />

<target name="js">
<echo>Working...</echo>

<mkdir dir="bin" />
<concat destfile="bin\main.js" fixlastline="true">
<fileset dir="dev\${yak.path}js" includes="yakbootstrap*.js" excludes="${js.files}" />
</concat>
<concat destfile="bin\main.js" fixlastline="true" append="true">
<filelist dir="dev\${yak.path}js" files="${js.files}" />
</concat>

<apply executable="java" verbose="true" dest="bin" failonerror="true" parallel="false">
<fileset dir="dev\${yak.path}js" includes="yakbootstrap*.js, konami.js, run.js" excludes="" />
<arg line="-jar"/>
<arg path="${closure.path}"/>
<arg value="--js"/>
<srcfile/>
<arg value="--js_output_file"/>
<targetfile/>
<mapper type="glob" from="*.js" to="*.min.js"/>
</apply>

<apply executable="java" verbose="true" dest="bin" failonerror="true" parallel="false">
<fileset dir="bin" includes="main.js"/>
<arg line="-jar"/>
<arg path="${closure.path}"/>
<arg value="--js"/>
<srcfile/>
<arg value="--js_output_file"/>
<targetfile/>
<mapper type="glob" from="*.js" to="*.min.js"/>
</apply>
<copy file="bin\main.min.js" todir="${yak.path}js" overwrite="true" />
<!--<delete file="bin\main.js" />-->

<mkdir dir="doc" />
<exec executable="cmd" dir="bin">
<arg line="/c yuidoc ."/>
</exec>
<copy todir="doc">
<fileset dir="bin\out" />
</copy>
<delete dir="bin\out" />
</target>

<target name="css">
<!--<concat destfile="bin\_style.css" fixlastline="true">
<filelist dir="dev\${yak.path}css" files="style.css" />
</concat>-->

<apply executable="java" verbose="true" dest="bin" failonerror="true" parallel="false">
<fileset dir="dev\${yak.path}css" includes="style.css"/>
<arg line="-jar"/>
<arg path="${yuicompressor.path}"/>
<arg value="--type"/>
<arg value="css"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
<mapper type="glob" from="*.css" to="*.css"/>
</apply>
<copy file="bin\style.css" todir="${yak.path}css" overwrite="true" />
</target>

<target name="html">
<copy file="dev\index.html" todir="." overwrite="true" />
<replaceregexp flags="gs">
<regexp pattern='(ui.min.js">\\x3C/script)(.*?)run.js' />
<substitution expression='\1\>\&apos;)\</script\>\ \<script type="text/javascript" src="resources/yakbootstrap/js/main.min.js' />
<fileset dir="." includes="index.html" />
</replaceregexp>
</target>

<target name="yakbootstrap" depends="js,css, html">
<echo message="Build complete."/>
</target>
</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值