ro.isdc.wro.extensions.processor.support.uglify
Class UglifyJs

java.lang.Object
  extended by ro.isdc.wro.extensions.processor.support.uglify.UglifyJs

public class UglifyJs
extends Object

The underlying implementation use untagged version (commited on 2012-09-08 14:15:12).

https://github.com/mishoo/UglifyJS.

The uglify script is resulted from merging of the following two scripts: parse-js.js, process.js.

Since:
1.3.1
Author:
Alex Objelean

Nested Class Summary
static class UglifyJs.Type
          The type of processing supported by UglifyJs library.
 
Field Summary
static String DEFAULT_UGLIFY_JS
          The name of the uglify script to be used by default.
 
Constructor Summary
UglifyJs(UglifyJs.Type uglifyType)
           
 
Method Summary
static UglifyJs beautifyJs()
          Factory method for creating the beautifyJs engine.
protected  String createOptionsAsJson()
          Reads by default options from options.js file located in the same package.
protected  InputStream getScriptAsStream()
           
 String process(String filename, String code)
           
 UglifyJs setReservedNames(String reservedNames)
          some libraries rely on certain names to be used, so this option allow you to exclude such names from the mangler.
static UglifyJs uglifyJs()
          Factory method for creating the uglifyJs engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_UGLIFY_JS

public static final String DEFAULT_UGLIFY_JS
The name of the uglify script to be used by default.

See Also:
Constant Field Values
Constructor Detail

UglifyJs

public UglifyJs(UglifyJs.Type uglifyType)
Parameters:
uglify - if true the code will be uglified (compressed and minimized), otherwise it will be beautified (nice formatted).
Method Detail

uglifyJs

public static UglifyJs uglifyJs()
Factory method for creating the uglifyJs engine.


beautifyJs

public static UglifyJs beautifyJs()
Factory method for creating the beautifyJs engine.


setReservedNames

public UglifyJs setReservedNames(String reservedNames)
some libraries rely on certain names to be used, so this option allow you to exclude such names from the mangler. For example, to keep names require and $super intact you'd specify –reserved-names "require,$super".

Parameters:
reservedNames - the reservedNames to set

getScriptAsStream

protected InputStream getScriptAsStream()
Returns:
the stream of the uglify script. Override this method to provide a different script version.

process

public String process(String filename,
                      String code)
               throws IOException
Parameters:
data - js content to process.
Returns:
packed js content.
Throws:
IOException

createOptionsAsJson

protected String createOptionsAsJson()
                              throws IOException
Reads by default options from options.js file located in the same package. This is an example of how the options could look like:
 {
    codegen_options: {
      beautify: false,
      space_colon: false
    },
    squeeze: true,
    dead_code: true,
    mangle: true
 }
 

Returns:
json representation of options.
Throws:
IOException


Copyright © 2008-2013. All Rights Reserved.