Skip to content

A Rollup plugin to minify the generated bundle with Terser

License

Notifications You must be signed in to change notification settings

sjinks/rollup-plugin-terser

Repository files navigation

rollup-plugin-terser

Build and Test Quality Gate Status CodeQL Analysis Dependency Review

A Rollup plugin to minify the generated bundle with Terser.

This is a complete rewrite of TrySound/rollup-plugin-terser.

Main differences:

  • the code is written in TypeScript;
  • this plugin supports both Rollup 2 and Rollup 3;
  • the implementation is more lightweight and probably less resource-consuming, but it does not use workers (therefore, it could be slower).

Installation

npm i -D @wwa/rollup-plugin-terser

Usage

import { rollup } from 'rollup';
import { terser } from '@wwa/rollup-plugin-terser';

rollup({
  input: 'file.js',
  plugins: [
    terser(),
  ],
});

terser accepts an optional options parameter, which is the MinifyOptions object.

The plugin automatically sets the following options:

  • module: true if the output format is esm or es;
  • toplevel: true if the output format is cjs;
  • sourcemap is always inferred from rollup's options.