https://github.com/sjinks/rollup-plugin-terser
A Rollup plugin to minify the generated bundle with Terser
https://github.com/sjinks/rollup-plugin-terser
minify minify-javascript rollup rollup-plugin terser
Last synced: about 1 month ago
JSON representation
A Rollup plugin to minify the generated bundle with Terser
- Host: GitHub
- URL: https://github.com/sjinks/rollup-plugin-terser
- Owner: sjinks
- License: mit
- Created: 2022-10-14T19:18:56.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-04-08T03:27:54.000Z (about 1 month ago)
- Last Synced: 2025-04-08T04:26:18.957Z (about 1 month ago)
- Topics: minify, minify-javascript, rollup, rollup-plugin, terser
- Language: TypeScript
- Homepage:
- Size: 1.81 MB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup-plugin-terser
[](https://github.com/sjinks/rollup-plugin-terser/actions/workflows/ci.yml)
[](https://sonarcloud.io/summary/new_code?id=sjinks_rollup-plugin-terser)
[](https://github.com/sjinks/rollup-plugin-terser/actions/workflows/codeql-analysis.yml)
[](https://github.com/sjinks/rollup-plugin-terser/actions/workflows/dependency-review.yml)A Rollup plugin to minify the generated bundle with Terser.
This is a complete rewrite of [TrySound/rollup-plugin-terser](https://github.com/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
```bash
npm i -D @wwa/rollup-plugin-terser
```## Usage
```js
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](https://github.com/terser/terser#minify-options).
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.