Rollup plugin to minify generated bundles using UglifyJS. Current stable version is 6.0.4, compatible with Rollup >=0.66.0 <2. It runs UglifyJS in a worker per chunk, improving build performance for code-split projects, and displays errors with babel code frames. Supports source maps and configurable number of workers. Note: UglifyJS handles only ES5; for ES6+ use the similar rollup-plugin-terser. This plugin has undergone several breaking changes in major versions, including moving to worker-based uglification (v5) and reverting from uglify-es back to uglify-js (v4).
npm install rollup-plugin-uglifyVerified import paths — ran on the pinned version, not inferred.
Basic Rollup configuration using rollup-plugin-uglify to minify output with source maps and custom comments.
import { uglify } from 'rollup-plugin-uglify'Switch to rollup-plugin-terser if you need ES6+ minification.
Use { sourcemap: true } instead of { sourceMap: true }Replace with rollup-plugin-terser if your code contains ES6+ syntax.
Check rollup version; consider using rollup-plugin-terser for Rollup >=2.
Use named import: import { uglify } from 'rollup-plugin-uglify'Ensure uglify() is called with an object: uglify({ numWorkers: 2 })Use rollup-plugin-terser instead, or transpile code to ES5 first.