{"id":20637,"library":"uglifyjs-webpack-plugin","title":"UglifyJS Webpack Plugin","description":"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.","status":"maintenance","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/webpack-contrib/uglifyjs-webpack-plugin","tags":["javascript","uglify","uglify-js","uglify-es","webpack","webpack-plugin"],"install":[{"cmd":"npm install uglifyjs-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add uglifyjs-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add uglifyjs-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Works as a webpack plugin, requires webpack 4+","package":"webpack","optional":false}],"imports":[{"note":"This package provides a CommonJS default export; ESM import may fail in some bundlers.","wrong":"import UglifyJsPlugin from 'uglifyjs-webpack-plugin';","symbol":"UglifyJsPlugin","correct":"const UglifyJsPlugin = require('uglifyjs-webpack-plugin');"},{"note":"Named import is incorrect; the plugin is exported as a single default.","wrong":"import { UglifyJsPlugin } from 'uglifyjs-webpack-plugin';","symbol":"UglifyJsPlugin","correct":"const UglifyJsPlugin = require('uglifyjs-webpack-plugin');"},{"note":"If using ESM, use default import, but ensure your environment supports it. CJS require() is safer.","wrong":null,"symbol":"default","correct":"import UglifyJsPlugin from 'uglifyjs-webpack-plugin';"}],"quickstart":{"code":"const UglifyJsPlugin = require('uglifyjs-webpack-plugin');\n\nmodule.exports = {\n  mode: 'production',\n  optimization: {\n    minimizer: [\n      new UglifyJsPlugin({\n        cache: true,\n        parallel: true,\n        sourceMap: true,\n        uglifyOptions: {\n          compress: {\n            drop_console: true,\n          },\n          output: {\n            comments: false,\n          },\n        },\n      }),\n    ],\n  },\n};\n","lang":"javascript","description":"Configures webpack to use UglifyJS plugin with caching, parallelization, source maps, and options to remove console logs and comments."},"warnings":[{"fix":"For ES6+ support, migrate to terser-webpack-plugin.","message":"uglify-es has been abandoned; uglifyjs-webpack-plugin switched back to uglify-js in v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use terser-webpack-plugin for active development and ES6+ minification.","message":"This plugin is in maintenance mode; no new features are being added.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set parallel: false in plugin options.","message":"Parallelization may fail on Windows Subsystem for Linux (WSL); disable with parallel: false.","severity":"gotcha","affected_versions":">=2.1.3"},{"fix":"Set cache to a custom path or disable cache in CI.","message":"Default cache directory is node_modules/.cache/uglifyjs-webpack-plugin; may cause issues in CI environments.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use optimization: { minimizer: [new UglifyJsPlugin()] } in webpack config.","message":"Plugin options must be placed under webpack optimization.minimizer, not under plugins.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Explicitly set extractComments option to control comment extraction.","message":"Default extract comment condition is case insensitive, may produce different results than v1.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Move the plugin instance to optimization: { minimizer: [new UglifyJsPlugin()] }.","cause":"Plugin is placed directly in plugins array instead of optimization.minimizer.","error":"Error: Plugin could not be used because optimization.minimizer is not an array."},{"fix":"Use: const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); new UglifyJsPlugin();","cause":"Incorrect import or missing 'new' keyword when instantiating plugin.","error":"TypeError: Cannot read property 'call' of undefined"},{"fix":"Ensure uglify-js version 2.x is installed (npm install uglify-js@2).","cause":"Package depends on uglify-js v2, but uglify-js v3 is installed.","error":"Error: uglify-js@3.x is not compatible with this plugin."},{"fix":"Set parallel: false or ensure worker-farm is properly installed.","cause":"Setting parallel: true on platforms with a single CPU or where worker farm fails.","error":"UglifyJsPlugin: parallel option not supported in single-threaded mode"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}