简体   繁体   English

YUI压缩器将所有javascripts文件压缩为“ min.js”

[英]YUI compressor compress all javascripts files into 'min.js'

I want to compress all the javascripts files in a folder to 'min.js', however, the '*' seems doesn't work. 我想将文件夹中的所有javascripts文件压缩为“ min.js”,但是,“ *”似乎不起作用。 Following is my 'build.xml' 以下是我的“ build.xml”

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="compressScript" name="compress">

    <target name="compressScript">

        <exec executable="java" failonerror="true">
            <arg line="-jar yui/yuicompressor-2.4.8.jar --nomunge -o '.js$:.min.js' '*.js'"/>
        </exec>

    </target>

</project>

The errors are like this: 错误是这样的:

compressScript:
 [exec] java.io.FileNotFoundException: *.js (No such file or directory)
 [exec]     at java.io.FileInputStream.open(Native Method)
 [exec]     at java.io.FileInputStream.<init>(FileInputStream.java:106)
 [exec]     at java.io.FileInputStream.<init>(FileInputStream.java:66)
 [exec]     at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:133)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [exec]     at java.lang.reflect.Method.invoke(Method.java:597)
 [exec]     at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)

If I change the '*.js' to a certain name like 'example.js', it compressed exmaple.js into example.min.js in the same folder. 如果将“ * .js”更改为类似“ example.js”的名称,则会将exmaple.js压缩到同一文件夹中的example.min.js中。 So what should I do to compress all the scripts in that folder? 那么,该怎么压缩该文件夹中的所有脚本?

I used like this: 我曾经这样:

<apply executable="java" parallel="false">
        <fileset dir="${root}/js-no-console" includes="*.js"/>
        <arg line="-jar"/>
        <arg path="${root}/${tool.yuicompressor}"/>
        <srcfile/>
        <redirector alwayslog="true">
            <outputmapper type="glob" from="*.js" to="${root}/${js.min.dir}/*-min.js"/>
        </redirector>
    </apply>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM