使用ANT合并JS/CSS文件

[安装配置ANT]

1.下载地址:http://ant.apache.org/bindownload.cgi

2.设置环境变量:
ANT_HOME:D:\ant\apache-ant-1.9.2
PATH:%ANT_HOME%\bin;

[合并文件]

1.编辑:build.xml

<project name="core" basedir="." xmlns:ac="antlib:net.sf.antcontrib" default="concat" >
    <description>Build File</description>

    <dirname property="core.current.dir" file="${ant.file.core}"/>
	<property name="build.dir" value="${current.dir}/../build"/>
	<property name="version" value="1.0"/>
    <property name="charset" value="gbk"/>

    <property name="core.build.dir" value="${build.dir}/"/>
    <property name="core.src.dir" value="${core.current.dir}"/>

    <target name="concat">
        <concat destfile="${core.build.dir}/example_btmp.js" encoding="${charset}" outputencoding="${charset}">
			<path path="${core.src.dir}/example1.js"/>
			<path path="${core.src.dir}/example2.js"/>
        </concat>
    </target>

</project>

2.执行ant

发表评论