You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
size-limit-action
v1.3.0
A GitHub action that compares the real cost of your JavaScript in every pull request
This action uses Size Limit (performance budget tool for JavaScript) to calculate the real cost of your JavaScript for end-users. The main features of this action are:
- Commenting pull requests with the comparison of Size Limit output.
- Rejecting a pull request if the cost exceeds the limit.
- Install Size Limit choosing the scenario that fits you better (JS Application, Big Libraries or Small Libraries).
- By default this action will try to build your PR by running
build
npm script located in yourpackage.json
. If something need to be done after dependencies are installed but before buildingpostinstall
npm script could be used. For example, using lerna:
"scripts": {
"postinstall": "lerna bootstrap",
"build": "lerna run build"
},
- Define Size limit configuration. For example (inside
package.json
):
"size-limit": [
{
"path": "dist/index.js",
"limit": "4500 ms"
}
]
- Add the following action inside
.github/workflows/size-limit.yml
name: "size"
on:
pull_request:
branches:
- master
jobs:
size:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v1
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
You can optionally specify a custom npm script to run instead of the default build
adding a build_script
option to the yml workflow shown above.
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: custom-build
- You are now all set
Pull requests, feature ideas and bug reports are very welcome. We highly appreciate any feedback.