rollup-plugin-terser ![Travis Build Status](https://travis-ci.org/TrySound/rollup-plugin-terser.svg)
Rollup plugin to minify generated es bundle. Uses terser under the hood.
Install
npm i rollup-plugin-terser -D
Usage
import { rollup } from "rollup";
import { terser } from "rollup-plugin-terser";
rollup({
entry: "main.js",
plugins: [terser()]
});
Options
terser(options);
options
- terser API options
options.sourcemap
- default: true
, type: boolean
. The only own option which is used to generate source maps and pass them to rollup.
Examples
If you'd like to preserve comments (for licensing for example), then you can specify a function to do this like so:
terser({
output: {
comments: function(node, comment) {
var text = comment.value;
var type = comment.type;
if (type == "comment2") {
return /@preserve|@license|@cc_on/i.test(text);
}
}
}
});
Alternatively, you can also choose to keep all comments (e.g. if a licensing header has already been prepended by a previous rollup plugin):
terser({
output: {
comments: "all"
}
});
See Terser documentation for further reference.
License
MIT © Bogdan Chadkin