Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.31 KB

README.md

File metadata and controls

60 lines (47 loc) · 1.31 KB

dev

dev

Show instructions
  1. Install the preset:

    $ npm install --save-dev size-limit @size-limit/file
  2. Add the size-limit section and the size script to your package.json:

    + "size-limit": [
    +   {
    +     "path": "dist/app-*.js"
    +   }
    + ],
      "scripts": {
        "build": "webpack ./webpack.config.js",
    +   "size": "npm run build && size-limit",
        "test": "jest && eslint ."
      }
  3. 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
  4. 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"
        }
      ],
  5. 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"
      }
  6. If you don’t have a continuous integration service running, don’t forget to add one — start with [Travis CI].