Rollup plugin to minify generated bundle. Based on rollup-plugin-terser. Rollup plugin to minify generated bundle (based on terser with checksum signature enhance)
Install
yarn add rollup-plugin-jspacker --dev
Note: this package requires rollup@0.66 and higher (including rollup@1.0.0)
Usage
import { rollup } from "rollup";
import { minify } from "rollup-plugin-jspacker";
rollup({
input: "main.js",
plugins: [minify()]
});
Why named export?
- Module is a namespace. Default export often leads to function/component per file dogma and makes code less maintainable.
- Interop with commonjs is broken in many cases or hard to maintain.
- Show me any good language with default exports. It's historical javascriptism.
Options
see https://github.com/TrySound/rollup-plugin-terser#options
Examples
include/exclude
If you'd like that only some of the files will be minify, then you can filter by include
and exclude
to do this like so:
// rollup.config.js
import { minify } from "rollup-plugin-jspacker";
export default {
input: "index.js",
output: [
{ file: 'lib.js', format: 'cjs' },
{ file: 'lib.min.js', format: 'cjs' },
{ file: 'lib.esm.js', format: 'es' },
{ dir: '.', entryFileNames: 'lib-[format].js', format: 'iife' }
],
plugins: [
minify({
include: [/^.+\.min\.js$/, '*esm*'],
exclude: [ 'some*' ]
})
]
};
See Terser documentation for further reference.
License
MIT © Allex Wang