vlad 6f123ff03e 18.07 | 6 lat temu | |
---|---|---|
.. | ||
dist | 6 lat temu | |
lib | 6 lat temu | |
node_modules | 6 lat temu | |
CHANGELOG.md | 6 lat temu | |
LICENSE | 6 lat temu | |
README.md | 6 lat temu | |
package.json | 6 lat temu |
This plugin uses UglifyJS v2 to minify your JavaScript.
Note 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.
With Yarn:
yarn add uglifyjs-webpack-plugin --dev
With npm:
npm install uglifyjs-webpack-plugin --save-dev
Important! The plugin has a peer dependency to uglify-js, so in order to use the plugin, also uglify-js has to be installed. The currently (2017/1/25) available uglify-js npm packages; however, do not support minification of ES6 code. In order to support ES6, an ES6-capable, a.k.a. harmony, version of UglifyJS has to be provided.
If your minification target is ES6:
yarn add git://github.com/mishoo/UglifyJS2#harmony-v2.8.22 --dev
If your minification target is ES5:
yarn add uglify-js --dev
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {...},
output: {...},
module: {...},
plugins: [
new UglifyJSPlugin()
]
};
This plugin supports UglifyJS features as discussed below:
Property | Type | Default | Description |
---|---|---|---|
compress | boolean, object | true | See UglifyJS documentation. |
mangle | boolean, object | true | See below. |
beautify | boolean | false | Beautify output. |
output | An object providing options for UglifyJS OutputStream | Lower level access to UglifyJS output. | |
comments | boolean, RegExp, function(astNode, comment) -> boolean | Defaults to preserving comments containing /*! , /**! , @preserve or @license . |
Comment related configuration. |
extractComments | boolean, RegExp, function (astNode, comment) -> boolean, object | false | Whether comments shall be extracted to a separate file, see below. |
sourceMap | boolean | false | Use SourceMaps to map error message locations to modules. This slows down the compilation. Important! cheap source map options don't work with the plugin! |
test | RegExp, Array | /.js($|\?)/i |
Test to match files against. |
include | RegExp, Array | Test only include files. |
|
exclude | RegExp, Array | Files to exclude from testing. |
|
extractComments | boolean, RegExp, object | Extract comments to separate file (see details, since webpack 2.3.0) | |
warningsFilter | function(source) -> boolean | Allow to filter uglify warnings (since webpack 2.3.0) |
Juho Vepsäläinen | Joshua Wiens | Kees Kluskens |