A set of functions commonly used after tree shaking
npm install rollup-plugin-bundleutils[![NPM Package][npm]][npm-url]
[![DeepScan][deepscan]][deepscan-url]
A set of functions commonly used after tree shaking.
``sh
npm i -D rollup-plugin-bundleutils
yarn add -D rollup-plugin-bundleutils
`
`js
// rollup.config.js
import { timestamp, regex, babel, terser } from 'rollup-plugin-bundleutils';
export default {
// ...
plugins: [
regex([
[/^import\s.*[\r\n]+/gm, '']
]),
babel({
compact: false,
plugins: ['@babel/plugin-proposal-class-properties']
}),
terser({
output: {
preamble: // ${timestamp()}`
}
})
]
};
`js
import { timestamp } from 'rollup-plugin-bundleutils';
console.log(timestamp()); // 2017-09-19 4:55pm
`
JavaScript String replace after tree shaking. Expects an Array of regexp|substr, newSubstr|function pairs.
`js
// rollup.config.js
import { regex } from 'rollup-plugin-bundleutils';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'es'
},
plugins: [
regex([
[/^[\r\n]+export\s.*/gm, '']
])
]
};
`
Transpile bundle after tree shaking.
`js
// rollup.config.js
import { babel } from 'rollup-plugin-bundleutils';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'iife'
},
plugins: [
babel({
// Default
presets: [
['@babel/preset-env', { modules: false }]
]
})
]
};
`
Minify bundle after tree shaking.
`js
// rollup.config.js
import { terser } from 'rollup-plugin-bundleutils';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'iife'
},
plugins: [
terser()
]
};
``
* Releases
[npm]: https://img.shields.io/npm/v/rollup-plugin-bundleutils.svg
[npm-url]: https://www.npmjs.com/package/rollup-plugin-bundleutils
[deepscan]: https://deepscan.io/api/teams/20020/projects/23506/branches/715192/badge/grade.svg
[deepscan-url]: https://deepscan.io/dashboard#view=project&tid=20020&pid=23506&bid=715192