简体   繁体   中英

YUI Compressor: Output with line breaks using Ant

My Ant build script has this statement:

<java
    jar="../tools/yuicompressor-2.4.8.jar" fork="true"
    args="../js/navigation.js -o ../js/navigation.min.js">  
</java> 

The newly created file ../js/navigation.min.js is not formatted. Is there any way by which I can format the populated output file so that it isn't all on one line?

From the YUI Compressor documentation :

--line-break
  ...
  Specify 0 to get a line break after each semi-colon in JavaScript, and
  after each rule in CSS.

Here's how you would use --line-break in an Ant script:

<java jar="../tools/yuicompressor-2.4.8.jar" fork="true">
    <arg value="../js/navigation.js"/>
    <arg value="-o"/>
    <arg value="../js/navigation.min.js"/>
    <arg value="--line-break"/>
    <arg value="0"/>
</java>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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