Package Exports
- rollup-plugin-terser
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-terser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rollup-plugin-terser 
Rollup plugin to minify generated es bundle. Uses terser under the hood.
Install
yarn add rollup-plugin-terser --devNote: this package requires rollup@0.66 and higher (including rollup@1.0.0)
Usage
import { rollup } from "rollup";
import { terser } from "rollup-plugin-terser";
rollup({
input: "main.js",
plugins: [terser()]
});Options
⚠️ Caveat: any function used in options object cannot rely on its surrounding scope, since it is executed in an isolated context.
terser(options);options - terser API options
options.sourcemap: boolean
Generates source maps and passes them to rollup. Defaults to true.
options.numWorkers: number
Amount of workers to spawn. Defaults to the number of CPUs minus 1.
Examples
Comments
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") {
// multiline comment
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