Registry / devops / uglifyjs-webpack-plugin

uglifyjs-webpack-plugin

JSON →
library2.2.0jsnpmunverified

UglifyJS Webpack Plugin uses UglifyJS (v2) to minify JavaScript bundles generated by webpack. The latest stable version is 2.2.0, released July 2019, supporting webpack 4+ and Node 6.9+. It offers caching, parallelization, source maps, and advanced options like chunk filtering. However, it is now largely superseded by terser-webpack-plugin, which supports ES6+ and is the recommended minimizer for webpack 4+. This plugin switched back from uglify-es to uglify-js in v2.0.0, meaning it does not handle modern JavaScript (ES6+) out of the box. It is in maintenance mode with no active development.

npm install uglifyjs-webpack-plugin
INSTALL
IMPORT
SIG · UGLIFYJS-WEBPACK-P
U
uglifyjs-webpack-plugin
devopsjavascriptv2.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

UglifyJsPlugin
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
This package provides a CommonJS default export; ESM import may fail in some bundlers.
UglifyJsPlugin
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
import { UglifyJsPlugin } from 'uglifyjs-webpack-plugin';
Named import is incorrect; the plugin is exported as a single default.
default
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
If using ESM, use default import, but ensure your environment supports it. CJS require() is safer.

Configures webpack to use UglifyJS plugin with caching, parallelization, source maps, and options to remove console logs and comments.

const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); module.exports = { mode: 'production', optimization: { minimizer: [ new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: true, uglifyOptions: { compress: { drop_console: true, }, output: { comments: false, }, }, }), ], }, };
Debug
Known issues
breakinguglify-es has been abandoned; uglifyjs-webpack-plugin switched back to uglify-js in v2.0.0.
fix
For ES6+ support, migrate to terser-webpack-plugin.
affects: >=2.0.0
deprecatedThis plugin is in maintenance mode; no new features are being added.
fix
Use terser-webpack-plugin for active development and ES6+ minification.
affects: >=2.0.0
gotchaParallelization may fail on Windows Subsystem for Linux (WSL); disable with parallel: false.
fix
Set parallel: false in plugin options.
affects: >=2.1.3
gotchaDefault cache directory is node_modules/.cache/uglifyjs-webpack-plugin; may cause issues in CI environments.
fix
Set cache to a custom path or disable cache in CI.
affects: >=2.0.0
gotchaPlugin options must be placed under webpack optimization.minimizer, not under plugins.
fix
Use optimization: { minimizer: [new UglifyJsPlugin()] } in webpack config.
affects: >=2.0.0
breakingDefault extract comment condition is case insensitive, may produce different results than v1.
fix
Explicitly set extractComments option to control comment extraction.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Plugin could not be used because optimization.minimizer is not an array.
Plugin is placed directly in plugins array instead of optimization.minimizer.
fix
Move the plugin instance to optimization: { minimizer: [new UglifyJsPlugin()] }.
TypeError: Cannot read property 'call' of undefined
Incorrect import or missing 'new' keyword when instantiating plugin.
fix
Use: const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); new UglifyJsPlugin();
Error: uglify-js@3.x is not compatible with this plugin.
Package depends on uglify-js v2, but uglify-js v3 is installed.
fix
Ensure uglify-js version 2.x is installed (npm install uglify-js@2).
UglifyJsPlugin: parallel option not supported in single-threaded mode
Setting parallel: true on platforms with a single CPU or where worker farm fails.
fix
Set parallel: false or ensure worker-farm is properly installed.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
webpackrequiredWorks as a webpack plugin, requires webpack 4+
Agent activity
9 hits · last 30 days
node
6
Resources