You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 5, 2019. It is now read-only.
<p>This plugin uses <a href="https://github.com/mishoo/UglifyJS2/tree/v2.x">UglifyJS v2</a> to minify your JavaScript.<p>
16
16
</div>
17
17
18
+
18
19
> ℹ️ that webpack contains the same plugin under `webpack.optimize.UglifyJsPlugin`. This is a standalone version for those that want to control the version of UglifyJS. The documentation is valid apart from the installation instructions in that case.
19
20
20
21
<h2align="center">Install</h2>
21
22
22
23
```bash
23
-
npm install uglifyjs-webpack-plugin --save-dev
24
-
yarn add uglifyjs-webpack-plugin --dev
24
+
npm i -D uglifyjs-webpack-plugin
25
25
```
26
26
27
-
> ⚠️ The plugin has a peer dependency to uglify-es (UglifyJS), so in order to use the plugin, also uglify-js has to be installed.
27
+
> ⚠️ The plugin has a peer dependency to `uglify-es` (UglifyJS), so in order to use the plugin, also `uglify-es` has to be installed.
|**`output`**|`{Object}`|`{}`|An object providing options for UglifyJS [OutputStream](https://github.com/mishoo/UglifyJS2/blob/v2.x/lib/output.js) (Lower level access to `Uglifyjs` output)|
57
-
|**`comments`**|`{Boolean\|RegExp\|Function<(node, comment) -> {Boolean}>}`| Defaults to preserving comments containing `/*!`, `/**!`, `@preserve` or `@license`. |Comment related configuration|
55
+
|**`comments`**|`{Boolean\|RegExp\|`false`|Function<(node, comment) -> {Boolean}>}`| Defaults to preserving comments containing `/*!`, `/**!`, `@preserve` or `@license`|
58
56
|**`extractComments`**|`{Boolean\|RegExp\|Function<(node, comment) -> {Boolean\|Object}>}`|`false`| Whether comments shall be extracted to a separate file, (see [details](https://github.com/webpack/webpack/commit/71933e979e51c533b432658d5e37917f9e71595a), since webpack 2.3.0)|
59
-
|**`sourceMap`**|`{Boolean}`|`false`|Use SourceMaps to map error message locations to modules. This slows down the compilation. ⚠️ **`cheap-source-map` options don't work with the plugin!**|
60
-
|**`test`**|`{RegExp\|Array<RegExp>}`| <code>/\.js($|\?)/i</code> |Test to match files against|
57
+
|**`warningsFilter`**|`{Function(source) -> {Boolean}}`|``|Allow to filter uglify warnings (since webpack 2.3.0)|
61
58
|**`include`**|`{RegExp\|Array<RegExp>}`|`undefined`|Test only `include` files|
62
59
|**`exclude`**|`{RegExp\|Array<RegExp>}`|`undefined`|Files to `exclude` from testing|
63
-
|**`warningsFilter`**|{`Function(source) -> {Boolean}}`|``|Allow to filter uglify warnings (since webpack 2.3.0)|
60
+
|**`sourceMap`**|`{Boolean}`|`false`|Use SourceMaps to map error message locations to modules. This slows down the compilation. ⚠️ **`cheap-source-map` options don't work with the plugin!**|
64
61
62
+
### `test`
63
+
64
+
**webpack.config.js**
65
+
```js
66
+
[
67
+
newUglifyJSPlugin({ test:/\.js($|\?)/i })
68
+
]
69
+
```
70
+
71
+
### `output`
72
+
73
+
**webpack.config.js**
74
+
```js
75
+
[
76
+
newUglifyJSPlugin({ output: {...options} })
77
+
]
78
+
```
65
79
66
80
### `mangle`
67
81
68
82
`mangle (boolean|object)` - Passing `true` or an object enables and provides options for UglifyJS name mangling. See [UglifyJS documentation](https://github.com/mishoo/UglifyJS2/tree/v2.x#mangle) for mangle options. Example configuration, this will **not** mangle properties (see below):
69
83
84
+
**webpack.config.js**
70
85
```js
71
-
newUglifyJsPlugin({
72
-
mangle: {
73
-
// Skip mangling these
74
-
except: ['$super', '$', 'exports', 'require']
75
-
}
76
-
})
86
+
[
87
+
newUglifyJsPlugin({
88
+
mangle: {
89
+
// Skip mangling these
90
+
except: ['$super', '$', 'exports', 'require']
91
+
}
92
+
})
93
+
]
77
94
```
78
95
79
96
`mangle.props (boolean|object)` - Passing `true` or an object enables and provides options for UglifyJS property mangling - see [UglifyJS documentation](https://github.com/mishoo/UglifyJS2/tree/v2.x#mangleproperties-options) for mangleProperties options.
80
97
81
98
> ℹ️ the UglifyJS docs warn that [you will probably break your source if you use property mangling](https://github.com/mishoo/UglifyJS2/tree/v2.x#mangling-property-names---mangle-props), so if you aren’t sure why you’d need this feature, you most likely shouldn’t be using it! This is **not** enabled by default.
82
99
83
-
Example configuration, this will mangle both names and properties:
@@ -102,6 +157,41 @@ The `extractComments` option can be
102
157
-`banner`: The banner text that points to the extracted file and will be added on top of the original file. will be added to the original file. Can be `false` (no banner), a `string`, or a `function (string) -> string` that will be called with the filename where extracted comments have been stored. Will be wrapped into comment.
103
158
Default: `/*! For license information please see foo.js.LICENSE */`
0 commit comments