bundle-range

1.2.4 • Public • Published



Keep your library size in check based on bundlesize

 

Build Status Backers on Open Collective Sponsors on Open Collective Greenkeeper badge NPM Version js-standard-style Join us on Slack

NPM Downloads  

minimal setup

npm install bundlesize --save-dev

 

usage

Add it to your scripts in package.json

"scripts"{
  "test": "bundlesize"
}

 

Or you can use npx with NPM 5.2+.

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).

{
  "name": "your cool library",
  "version": "1.1.2",
  "bundlesize": [
    {
      "path": "./dist.js",
      "maxSize": "30 kB",
      "minSize": "3 kB"
    }
  ]
}

bundlesize also supports glob patterns

Example:

"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:

"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:

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?

⭐️ this repo

TODO

  • Work with other CI tools (AppVeyor, etc.)
  • Automate setup (setting env_var)

 

similar projects

license

MIT © siddharthkp

Package Sidebar

Install

npm i bundle-range

Weekly Downloads

0

Version

1.2.4

License

MIT

Unpacked Size

21.2 kB

Total Files

16

Last publish

Collaborators

  • obender