uglify-es-loader
Uglify loader for webpack(fork from uglify-loader, using terser@3)
To install
npm i -D uglify-es-loader
Use Case
Webpack has UglifyJSPlugin that uglifies the output after bundling.
In the applications that depend on thirdparty libraries you may want to uglify with mangling only your application code but not the code that you don't control.
Example
Webpack 1
module: {
loaders: [
{
test: /.*\/app\/.*\.js$/,
exclude: /.spec.js/,
loader: "uglify"
}
]
}
You can pass UglifyJS parameters via 'uglify-es-loader' property of webpack config.
module: {
loaders: [
{
test: /.*\/app\/.*\.js$/,
exclude: /.spec.js/,
loader: "uglify"
}
]
},
'uglify-es-loader': {
mangle: false
}
Webpack 2
module: {
rules: [
{
test: /.*\/app\/.*\.js$/,
exclude: /.spec.js/,
use: 'uglify-es-loader'
}
]
}
You can pass UglifyJS parameters via loader options.
module: {
rules: [
{
test: /.*\/app\/.*\.js$/,
exclude: /.spec.js/,
use: {
loader: 'uglify-es-loader',
options: {
mangle: false
}
}
}
]
}
Enable sourceMap
{
loader: 'uglify-es-loader',
options: {
enableSourceMap: true
}
}
Update