webpack-parallel-uglify-plugin

raw JSON →
2.0.0 verified Sat Apr 25 auth: no javascript maintenance

A webpack plugin that runs UglifyJS (or Terser) in parallel across multiple workers to speed up minification of bundled assets. Version 2.0.0 is the current stable release, but the project appears to be in maintenance mode with no recent updates (last release 2019). It leverages Node.js worker threads to distribute minification of each output file across available CPU cores, offering significant build time reductions for projects with many entry points. Compared to built-in webpack UglifyJS plugin, it can reduce minification time from minutes to seconds. Supports both UglifyJS (ES5) and Terser (ES6+), along with caching, file inclusion/exclusion by pattern, and source maps. Requires webpack as a peer dependency.

error Error: Cannot find module 'webpack-parallel-uglify-plugin'
cause Package not installed or import path incorrect.
fix
Run 'npm install webpack-parallel-uglify-plugin --save-dev' and ensure correct import statement.
error TypeError: ParallelUglifyPlugin is not a constructor
cause Using CommonJS require without accessing .default property.
fix
Use 'const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin').default;'
error Error: ParallelUglifyPlugin: you cannot use both uglifyJS and terser
cause Both minifier options provided simultaneously.
fix
Remove one of the options: either uglifyJS or terser.
deprecated The package is outdated and unmaintained; consider using 'terser-webpack-plugin' which is officially maintained by the webpack team.
fix Replace with 'terser-webpack-plugin' and update configuration accordingly.
breaking Cannot use both 'uglifyJS' and 'terser' options simultaneously. If both are provided, the plugin will throw an error.
fix Choose only one minifier: either UglifyJS or Terser.
gotcha With UglifyJS (not Terser), ES6+ syntax will cause an error because UglifyJS only supports ES5. Use terser option for ES6+.
fix Set terser options instead of uglifyJS if your code uses ES6+.
npm install webpack-parallel-uglify-plugin
yarn add webpack-parallel-uglify-plugin
pnpm add webpack-parallel-uglify-plugin

Shows how to configure the plugin with UglifyJS options, caching, and worker count.

// webpack.config.js
import ParallelUglifyPlugin from 'webpack-parallel-uglify-plugin';

export default {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: '/dist',
  },
  plugins: [
    new ParallelUglifyPlugin({
      workerCount: 4,
      uglifyJS: {
        output: {
          beautify: false,
        },
        compress: {
          drop_console: true,
        },
      },
      cacheDir: '/path/to/cache',
      sourceMap: false,
      include: /\.js$/,
      exclude: /node_modules/,
      test: /\.js$/,
    }),
  ],
};