diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-01-04 11:24:29 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-01-04 11:25:13 +0200 |
commit | 130c623be74ea010b11222d43eb23a181d36cd8a (patch) | |
tree | 9fee27f4e9fcd0ccb0598d71602548dc1239db8e /tools | |
parent | 47c9895d591f2b83259302416663cd0ed44b26eb (diff) | |
download | tracifyjs-130c623be74ea010b11222d43eb23a181d36cd8a.tar.gz tracifyjs-130c623be74ea010b11222d43eb23a181d36cd8a.zip |
Support `output`, `mangle` and `compress` options to `UglifyJS.minify`.
Close #57
Close #86
Close #33
Diffstat (limited to 'tools')
-rw-r--r-- | tools/node.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/node.js b/tools/node.js index be3cd93d..cf87628d 100644 --- a/tools/node.js +++ b/tools/node.js @@ -56,6 +56,9 @@ exports.minify = function(files, options) { inSourceMap : null, fromString : false, warnings : false, + mangle : {}, + output : null, + compress : {} }); if (typeof files == "string") files = [ files ]; @@ -73,16 +76,20 @@ exports.minify = function(files, options) { }); // 2. compress - toplevel.figure_out_scope(); - var sq = UglifyJS.Compressor({ - warnings: options.warnings, - }); - toplevel = toplevel.transform(sq); + if (options.compress) { + var compress = { warnings: options.warnings }; + UglifyJS.merge(compress, options.compress); + toplevel.figure_out_scope(); + var sq = UglifyJS.Compressor(compress); + toplevel = toplevel.transform(sq); + } // 3. mangle - toplevel.figure_out_scope(); - toplevel.compute_char_frequency(); - toplevel.mangle_names(); + if (options.mangle) { + toplevel.figure_out_scope(); + toplevel.compute_char_frequency(); + toplevel.mangle_names(options.mangle); + } // 4. output var map = null; @@ -95,7 +102,11 @@ exports.minify = function(files, options) { orig: inMap, root: options.sourceRoot }); - var stream = UglifyJS.OutputStream({ source_map: map }); + var output = { source_map: map }; + if (options.output) { + UglifyJS.merge(output, options.output); + } + var stream = UglifyJS.OutputStream(output); toplevel.print(stream); return { code : stream + "", |