如何使用Ant构建脚本YUI的COM pressor的JavaScript和CSS [英] How to use YUI Compressor in Ant build script for javascript and css

查看:115
本文介绍了如何使用Ant构建脚本YUI的COM pressor的JavaScript和CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在几天的寻找如何在我终于得到它的工作Ant构建脚本中使用的COM YUI pressor。许多老的例子(小于2010)存在创建一个Ant任务,并使用你的构建脚本中,但这是矫枉过正,我

After a couple of days searching for how to use the YUI Compressor in an Ant build script I have finally got it working. Many old examples (<2010) exist for creating an Ant task and using that within your build script, but that was overkill for me.

许多例子也老要求蚂蚁或配置Ant任务的一些更深入的了解。下面的解决方法是什么快速,简便和有效的我。

Many of the examples are also old and require some greater knowledge of Ant or configuring Ant tasks. The solution below is simply what was quick, easy and effective for me.

推荐答案

下面加入到我的&中的一个靶标GT; 标记有全部在一个目录中COM pressed JavaScript文件。这些文件保留其原来的名字。要为CSS做到这一点只需将JS到CSS,并相应更新的路径。

The below was added to one of my <target> tags to have all the javascript files in a single directory compressed. These files retain their original name. To do this for CSS simply switch the 'js' to 'css' and update the paths accordingly.

这与YUI的COM pressor ​​2.4.7做,我运行Ant构建脚本它在Eclipse朱诺没有任何改变类路径或设置其他修改。

This was done with YUI Compressor 2.4.7 and I run the Ant build script it in Eclipse Juno without any changes to class paths or other modifications of settings.

<!-- Minimizing Javascript files -->
    <echo message="Compressing Javascript files at location: ${build.root}/resources/js/*.js" />
    <java jar="c:/dev/lib/yuicompressor-2.4.7/build/yuicompressor.jar" fork="true">
        <arg value="${build.root}/resources/js/*.js" /> <!-- input path for JS files -->
        <!--<arg value="-v" /> --><!-- Turn on verbose -->
        <arg value="-o" />
        <arg value="'.js$:.js'" />
        <arg value="${build.root}/resources/js/*.js" /> <!-- output path for JS files -->
        <classpath>
            <pathelement location="c:/dev/lib/yuicompressor-2.4.7/build/yuicompressor.jar"/>
        </classpath>
    </java>

请随意改进这个答案。上述解决方案适用于我,但我不是专家。

Please feel free to improve this answer. The solution above works for me, but I'm no expert.

这篇关于如何使用Ant构建脚本YUI的COM pressor的JavaScript和CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆