Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pschroen/rollup-plugin-bundleutils
A set of functions commonly used after tree shaking
https://github.com/pschroen/rollup-plugin-bundleutils
Last synced: 25 days ago
JSON representation
A set of functions commonly used after tree shaking
- Host: GitHub
- URL: https://github.com/pschroen/rollup-plugin-bundleutils
- Owner: pschroen
- License: mit
- Created: 2017-09-19T06:00:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T20:21:19.000Z (about 1 year ago)
- Last Synced: 2024-03-15T05:46:06.906Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 389 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - bundleutils - Set of commonly used utility functions. (Plugins / Output)
README
# rollup-plugin-bundleutils
[![NPM Package][npm]][npm-url]
[![DeepScan][deepscan]][deepscan-url]A set of functions commonly used after tree shaking.
## Install
```sh
npm i -D rollup-plugin-bundleutils# or
yarn add -D rollup-plugin-bundleutils
```## Usage
```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()}`
}
})
]
};
```## Exports
### timestamp
```js
import { timestamp } from 'rollup-plugin-bundleutils';console.log(timestamp()); // 2017-09-19 4:55pm
```### regex
[JavaScript String replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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, '']
])
]
};
```### babel
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 }]
]
})
]
};
```### terser [uglify|minify]
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()
]
};
```## Changelog
* [Releases](https://github.com/pschroen/rollup-plugin-bundleutils/releases)
## License
[MIT](LICENSE)
[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