dev
Show instructions
-
Install the preset:
$ npm install --save-dev size-limit @size-limit/file
-
Add the
size-limit
section and thesize
script to yourpackage.json
:+ "size-limit": [ + { + "path": "dist/app-*.js" + } + ], "scripts": { "build": "webpack ./webpack.config.js", + "size": "npm run build && size-limit", "test": "jest && eslint ." }
-
Here’s how you can get the size for your current project:
$ npm run size Package size: 30.08 kB with all dependencies, minified and gzipped
-
Now, let’s set the limit. Add 25% to the current total size and use that as the limit in your
package.json
:"size-limit": [ { + "limit": "35 kB", "path": "dist/app-*.js" } ],
-
Add the
size
script to your test suite:"scripts": { "build": "webpack ./webpack.config.js", "size": "npm run build && size-limit", - "test": "jest && eslint ." + "test": "jest && eslint . && npm run size" }
-
If you don’t have a continuous integration service running, don’t forget to add one — start with [Travis CI].