Keep your library size in check based on bundlesize
npm install bundle-range

Keep your library size in check based on bundlesize

  




#### minimal setup
``sh`
npm install bundlesize --save-dev
#### usage
Add it to your scripts in package.json
`json`
"scripts": {
"test": "bundlesize"
}
Or you can use npx with NPM 5.2+.
`sh`
npx bundlesize
#### configuration
#### 1) Add the path and maxSize in your package.json.
By default the gzipped size is tested. You can use the compression option to change this. (gzip, brotli, or none).
`json`
{
"name": "your cool library",
"version": "1.1.2",
"bundlesize": [
{
"path": "./dist.js",
"maxSize": "30 kB",
"minSize": "3 kB"
}
]
}
bundlesize also supports glob patterns
Example:
`json
"bundlesize": [
{
"path": "./dist/vendor-*.js",
"maxSize": "30 kB",
"minSize": "3 kB",
},
{
"path": "./dist/chunk-*.js",
"maxSize": "20 kB",
"minSize": "2 kB",
}
]
`
You can check for minimum size too.
Example:
`json
"bundlesize": [
{
"path": "./dist.js",
"maxSize": "100 kB",
"minSize": "2 kB"
},
{
"path": [
"./src/compressed-size.js",
"./src/files.js",
"./index.js"
],
"minSize": "1B",
"maxSize": "1MB",
"compression": "none"
}
]
`
This makes it great for using with applications that are bundled with another tool. It will match multiple files if necessary and create a new row for each file.
#### CLI
example usage:
`sh`
bundlesize -f "dist/*.js" -s 20kB
bundlesize -f "dist/*.js" -s 20kB --min-size 15kB
For more granular configuration, we recommend configuring it in the package.json` (documented above).
#### like it?
:star: this repo
#### TODO
- Work with other CI tools (AppVeyor, etc.)
- Automate setup (setting env_var)
#### similar projects
- BuildSize - GitHub App, no manual configuration required
- travis-weigh-in - Uses Python rather than Node.js
- size-limit - Uses webpack, builds your files for you.
#### license
MIT © siddharthkp