add --mangle-props
This commit is contained in:
parent
7aad7fef03
commit
177c9a09ed
22
README.md
22
README.md
|
|
@ -57,9 +57,9 @@ a double dash to prevent input files being used as option arguments:
|
||||||
The available options are:
|
The available options are:
|
||||||
|
|
||||||
```
|
```
|
||||||
-h, --help output usage information
|
-h, --help Print usage information.
|
||||||
-V, --version output the version number
|
-V, --version Print version number.
|
||||||
-p --parse <options> Specify parser options:
|
-p, --parse <options> Specify parser options:
|
||||||
`acorn` Use Acorn for parsing.
|
`acorn` Use Acorn for parsing.
|
||||||
`bare_returns` Allow return outside of functions.
|
`bare_returns` Allow return outside of functions.
|
||||||
Useful when minifying CommonJS
|
Useful when minifying CommonJS
|
||||||
|
|
@ -70,12 +70,16 @@ The available options are:
|
||||||
a program (for parsing JSON).
|
a program (for parsing JSON).
|
||||||
`spidermonkey` Assume input files are SpiderMonkey
|
`spidermonkey` Assume input files are SpiderMonkey
|
||||||
AST format (as JSON).
|
AST format (as JSON).
|
||||||
-c --compress [options] Enable compressor/specify compressor options:
|
-c, --compress [options] Enable compressor/specify compressor options:
|
||||||
`pure_funcs` List of functions that can be safely
|
`pure_funcs` List of functions that can be safely
|
||||||
removed when their return values are
|
removed when their return values are
|
||||||
not used.
|
not used.
|
||||||
-m --mangle [options] Mangle names/specify mangler options.
|
-m, --mangle [options] Mangle names/specify mangler options.
|
||||||
-b --beautify [options] Beautify output/specify output options:
|
--mangle-props [options] Mangle properties/specify mangler options:
|
||||||
|
`debug` Add debug prefix and suffix.
|
||||||
|
`ignore_quoted` Only mangle unquoted properies.
|
||||||
|
`regex` Only mangle matched property names.
|
||||||
|
-b, --beautify [options] Beautify output/specify output options:
|
||||||
`beautify` Enabled with `--beautify` by default.
|
`beautify` Enabled with `--beautify` by default.
|
||||||
`preamble` Preamble to prepend to the output. You
|
`preamble` Preamble to prepend to the output. You
|
||||||
can use this to insert a comment, for
|
can use this to insert a comment, for
|
||||||
|
|
@ -90,7 +94,7 @@ The available options are:
|
||||||
`wrap_iife` Wrap IIFEs in parenthesis. Note: you may
|
`wrap_iife` Wrap IIFEs in parenthesis. Note: you may
|
||||||
want to disable `negate_iife` under
|
want to disable `negate_iife` under
|
||||||
compressor options.
|
compressor options.
|
||||||
-o --output <file> Output file (default STDOUT). Specify "spidermonkey"
|
-o, --output <file> Output file (default STDOUT). Specify "spidermonkey"
|
||||||
to dump SpiderMonkey AST format (as JSON) to STDOUT.
|
to dump SpiderMonkey AST format (as JSON) to STDOUT.
|
||||||
--comments [filter] Preserve copyright comments in the output. By
|
--comments [filter] Preserve copyright comments in the output. By
|
||||||
default this works like Google Closure, keeping
|
default this works like Google Closure, keeping
|
||||||
|
|
@ -105,9 +109,9 @@ The available options are:
|
||||||
code removal or cascading statements into
|
code removal or cascading statements into
|
||||||
sequences.
|
sequences.
|
||||||
--config-file <file> Read `minify()` options from JSON file.
|
--config-file <file> Read `minify()` options from JSON file.
|
||||||
-d --define <expr>[=value] Global definitions.
|
-d, --define <expr>[=value] Global definitions.
|
||||||
--ie8 Support non-standard Internet Explorer 8.
|
--ie8 Support non-standard Internet Explorer 8.
|
||||||
Equivalent to setting `screw_ie8: false` in `minify()`
|
Equivalent to setting `ie8: true` in `minify()`
|
||||||
for `compress`, `mangle` and `output` options.
|
for `compress`, `mangle` and `output` options.
|
||||||
By default UglifyJS will not try to be IE-proof.
|
By default UglifyJS will not try to be IE-proof.
|
||||||
--keep-fnames Do not mangle/drop function names. Useful for
|
--keep-fnames Do not mangle/drop function names. Useful for
|
||||||
|
|
|
||||||
17
bin/uglifyjs
17
bin/uglifyjs
|
|
@ -18,14 +18,15 @@ program._name = info.name;
|
||||||
program.version(info.version);
|
program.version(info.version);
|
||||||
program.parseArgv = program.parse;
|
program.parseArgv = program.parse;
|
||||||
program.parse = undefined;
|
program.parse = undefined;
|
||||||
program.option("-p --parse <options>", "Specify parser options.", parseJS("parse", true));
|
program.option("-p, --parse <options>", "Specify parser options.", parseJS("parse", true));
|
||||||
program.option("-c --compress [options]", "Enable compressor/specify compressor options.", parseJS("compress", true));
|
program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parseJS("compress", true));
|
||||||
program.option("-m --mangle [options]", "Mangle names/specify mangler options.", parseJS("mangle", true));
|
program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parseJS("mangle", true));
|
||||||
program.option("-b --beautify [options]", "Beautify output/specify output options.", parseJS("beautify", true));
|
program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parseJS("mangle-props", true));
|
||||||
program.option("-o --output <file>", "Output file (default STDOUT).");
|
program.option("-b, --beautify [options]", "Beautify output/specify output options.", parseJS("beautify", true));
|
||||||
|
program.option("-o, --output <file>", "Output file (default STDOUT).");
|
||||||
program.option("--comments [filter]", "Preserve copyright comments in the output.");
|
program.option("--comments [filter]", "Preserve copyright comments in the output.");
|
||||||
program.option("--config-file <file>", "Read minify() options from JSON file.");
|
program.option("--config-file <file>", "Read minify() options from JSON file.");
|
||||||
program.option("-d --define <expr>[=value]", "Global definitions.", parseJS("define"));
|
program.option("-d, --define <expr>[=value]", "Global definitions.", parseJS("define"));
|
||||||
program.option("--ie8", "Support non-standard Internet Explorer 8.");
|
program.option("--ie8", "Support non-standard Internet Explorer 8.");
|
||||||
program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
|
program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
|
||||||
program.option("--self", "Build UglifyJS2 as a library (implies --wrap UglifyJS)");
|
program.option("--self", "Build UglifyJS2 as a library (implies --wrap UglifyJS)");
|
||||||
|
|
@ -73,6 +74,10 @@ if (program.define) {
|
||||||
if (program.keepFnames) {
|
if (program.keepFnames) {
|
||||||
options.keep_fnames = true;
|
options.keep_fnames = true;
|
||||||
}
|
}
|
||||||
|
if (program.mangleProps) {
|
||||||
|
if (typeof options.mangle != "object") options.mangle = {};
|
||||||
|
options.mangle.properties = program.mangleProps;
|
||||||
|
}
|
||||||
if (program.parse) {
|
if (program.parse) {
|
||||||
if (program.parse.acorn || program.parse.spidermonkey) {
|
if (program.parse.acorn || program.parse.spidermonkey) {
|
||||||
if (program.sourceMap) fatal("ERROR: inline source map only works with built-in parser");
|
if (program.sourceMap) fatal("ERROR: inline source map only works with built-in parser");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user