-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathUglify.node_cli.txt
137 lines (126 loc) · 11.5 KB
/
Uglify.node_cli.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
┏━━━━━━━━━━━━┓
┃ UGLIFY ┃
┗━━━━━━━━━━━━┛
SOURCE MAPS ==> #Files
# - MINIFIED.js
# - contains //# sourceMappingURL=/PATH/TO/MINIFIED.js.map
# or HTTP header X-SourceMap: /PATH/TO/MINIFIED.js.map
# - /PATH/TO/MINIFIED.js.map:
# - path is SOURCE-MAP-URL (def: same as MINIFIED.js + ".map")
# - Points to SOURCE-MAP-ROOT-DIR/SOURCE.js or, if inline source map,
# contains it
# - SOURCE-MAP-ROOT-DIR/SOURCE.js:
# - SOURCE is input FILE... of uglifyjs
# - SOURCE-MAP-ROOT-DIR: def is "."
#Relative folders are relative to MINIFIED.js
#When using absolute folders, must use them in SOURCE-MAP-URL + SOURCE-MAP-ROOT
#then use -p NUM to strip first folders
#When loading MINIFIED.js, downloads async. MINIFIED.js.map then SOURCE.js
#which becomes available for debugging.
VERSION ==> #2.4.15
#There is also an API to use uglifyjs from JavaScript (see online doc)
uglifyjs FILE... #Minimy JavaScript code or JSON.
#FILE can be - for stdin
--output FILE #Output (déf: stdout)
--source-map FILE #Creates a source map, FILE used by browser developer tool to debug minified
#code. Map point variables to unminimied file so that debugging can happen
#in unminimied file even when minified file is runtime.
#FILE should be output name with ".map", pointing to unminimied files in
#DIR/FILE:
# --source-map-root DIR (déf: same folder)
# --source-map-url FILE (déf: same as --source-map FILE, + ".map")
# -p NUM: see above
# --source-map-include-sources: see above
--in-source-map FILE #Use this with the CoffeeScript source map when using CoffeeScript.
--mangle #Minify variable names, except toplevel and ones used in eval()
#Can use --reserved "VAR..." to avoid some to be minified.
--compress "[VAR[=VAL]]..." #Higher minification, with options (all def true unless otherwise):
# - sequences: join consecutive statements with the "comma operator"
# - properties: optimize property access: a["foo"] -> a.foo
# - dead_code: discard unreachable code
# - drop_debugger: discard "debugger" statements
# - conditionals: optimize if-s and conditional expressions
# - comparisons: optimize comparisons
# - evaluate: evaluate constant expressions
# - booleans: optimize boolean expressions
# - loops: optimize loops
# - unused: drop unused variables/functions
# - hoist_funs: hoist function declarations
# - if_return: optimize if-s followed by return/continue
# - join_vars: join var declarations
# - cascade: try to cascade `right` into `left` in sequences
# - side_effects: drop side-effect-free statements
# - warnings: warn about potentially dangerous optimizations/code
# - negate_iife
# - pure_getters (def: false): put true if no "get methods", i.e. VAR.VAR2
# is assured to have no side-effects
# - pure_funcs FUNC_ARR (def: null): functions with no side effects
# - drop_console BOOL (def: false): drop console.*
# - hoist_vars (def: false): hoist variable declarations
# - unsafe (def: false): some unsafe optimizations, that assume that
# native types prototypes have not been changed
--comments REGEXP_STR #Keep comments matching REGEXP (e.g. copyright notice)
--expr #Use when FILE is JSON not JavaScript.
--screw-ie8 #Gives better optimization but not IE8 compatible.
--define "VAR=VAL..." #Sets some variables at global level during optimization, e.g.
#{ DEBUG: false }, all if ( DEBUG ) { ... } will be dropped.
--preamble STR #Put in header first (e.g. licence)
-b "[VAR[=VAL]]" #Beautify code instead of minification. Options VAR=VAL:
# - beautify (def: false): beautify output
# - indent_start (def: 0): start indentation on every line
# - indent_level (def: 4): indentation level
# - quote_keys (def: false): quote all keys in object literals
# - space_colon (def: true): add a space after colon signs
# - width (def: 80): informative maximum line width
# - ascii_only (def: false): encodes Unicode characters as ASCII
# - inline_script (def: false): escape "</script"
# - bracketize (def: false): use brackets in all statements
# - semicolons (def: true): use semicolons to separate statements
# (otherwise, newlines)
--wrap #Wraps in UMD
UGLIFY-JS.minify(FILE[_ARR][, OBJ2]) #As a Node module.
#Returns OBJ:
# - code STR
# - map STR
#OBJ2:
# - outSourceMap FILE
# - sourceRoot DIR
# - inSourceMap FILE
# - warnings BOOL
# - fromString BOOL: if true, use STR instead of FILE for input
# - mangle BOOL (def: true)
# - output OBJ:
# - max_line_len (def: 32000): maximum line length
# - ie_proof (def: true): like --screw-ie8
# - source_map (def: null): output a source map. OBJ has members
# file, root, orig
# - comments (def: false): output comments (can be true|REGEXP)
# - beautify options
# - compress OBJ: same options as --compress, plus:
# - global_defs (def: {}): like --define
grunt-contrib-uglify #Grunt plugin (0.9.1)
# - TASK "uglify"
# - TARGET src, dest
# - options:
# - same as UGLIFY-JS. See online doc for same option names.
# - report "min|gzip" (def: "min")
# - banner|footer "GEXP"
GULP-UGLIFY([OBJ]) #Does UGLIFY-JS(..., OBJ)
#OBJ also has:
# - output.preserveComments: "all", "some" (preserve Closure compiler
# comments) or FUNC(NODE)->BOOL
#To support source maps must use GULP-SOURCEMAPS, in order:
# .pipe(GULP-SOURCEMAPS.init())
# .pipe(GULP-CONCAT(FILE))
# .pipe(GULP-UGLIFY(...))
# .pipe(GULP-SOURCEMAPS.write(SOURCE-MAP-URL[, OBJ2]))
#SOURCE-MAP-URL is actually only the DIR:
# - filename is autogenerated with *.map
# - also change where MINIFIED.js.map is stored (creates directories)
# - use "." if MINIFIED.js is in same DIR as MINIFIED.js.map
#Where OBJ2 has:
# - includeContent BOOL: if true (def), inline source map
# - sourceRoot DIR: SOURCE-MAP-ROOT-DIR (déf: "/sources/").
# Only needed if includeContent false
# - addComment BOOL: if false, doesn't add //# sourceMappingURL (must then
# use header X-SourceMap