rollup-plugin-minify

raw JSON →
1.0.3 verified Mon Apr 27 auth: no javascript maintenance

A Rollup plugin that generates minified output files using UglifyJS, creating separate .min.js files with source maps. Version 1.0.3, last updated in 2017. It hooks into Rollup's ongenerate event to minify specific output formats (e.g., iife, cjs) after generation. Different from rollup-plugin-uglify which replaces the original output, this plugin creates additional files. Limited to UglifyJS (no Terser support) and has no updates since 2017.

error TypeError: minify is not a function
cause Trying to use destructured import on a default export.
fix
Use import minify from 'rollup-plugin-minify' instead of import { minify } from ...
error Error: The 'dest' option must be a string
cause Passing an object without a 'dest' property or incorrect type.
fix
Ensure each format option is either a string (dest) or an object with a 'dest' string property.
error Error: Cannot find module 'uglify-js'
cause uglify-js is a peer dependency not automatically installed.
fix
Run npm install uglify-js alongside rollup-plugin-minify.
deprecated Uses UglifyJS (not Terser) which is outdated for ES6+ code.
fix Consider using rollup-plugin-terser or @rollup/plugin-terser for modern JavaScript.
gotcha Options are per-format (e.g., iife, cjs) not global. Passing a string as value sets dest option.
fix Use object form for advanced options: { iife: { dest: 'file.min.js', mangle: false } }
gotcha Output files are written by the plugin itself, not by Rollup's output options. Ensure no conflicts.
fix Do not specify the same file in both the plugin and Rollup output.file.
gotcha Only works with formats iife, cjs, es, amd, umd. Other formats may not produce files.
fix Check the format matches one of these or test output.
npm install rollup-plugin-minify
yarn add rollup-plugin-minify
pnpm add rollup-plugin-minify

Shows basic usage: import default export and pass per-format minified output filenames.

import { rollup } from 'rollup';
import minify from 'rollup-plugin-minify';

rollup({
  input: 'src.js',
  plugins: [
    minify({ iife: 'iife.min.js', cjs: 'cjs.min.js' })
  ]
}).then(bundle => {
  // bundle generated
});