2.0.1 • Published 6 months ago
rollup-plugin-bundleutils v2.0.1
rollup-plugin-bundleutils
A set of functions commonly used after tree shaking.
Install
npm i -D rollup-plugin-bundleutils
# or
yarn add -D rollup-plugin-bundleutils
Usage
// 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()}`
}
})
]
};
Exports
timestamp
import { timestamp } from 'rollup-plugin-bundleutils';
console.log(timestamp()); // 2017-09-19 4:55pm
regex
JavaScript String replace after tree shaking. Expects an Array of regexp|substr, newSubstr|function
pairs.
// 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, '']
])
]
};
babel
Transpile bundle after tree shaking.
// 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 }]
]
})
]
};
terser uglify|minify
Minify bundle after tree shaking.
// rollup.config.js
import { terser } from 'rollup-plugin-bundleutils';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'iife'
},
plugins: [
terser()
]
};
Changelog
License
2.0.1
6 months ago
1.2.6
1 year ago
2.0.0
1 year ago
1.2.5
2 years ago
1.2.4
3 years ago
1.2.3
4 years ago
1.2.2
4 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
7 years ago
1.0.0
7 years ago