BundleWatch checks file sizes, ensuring bundled browser assets don't jump in file size.
Sharp increases in BundleWatch can signal that something is wrong, such as adding a package that bloats the slug, an incorrect import, or forgetting to minify.
Inspired by Siddharth Kshetrapal's bundlesize
Install the BundleWatch package:
npm install bundlewatch --save-dev
Add some basic configuration to your package.json
{
"name": "my package name",
"version": "0.0.1",
"bundlewatch": {
"files": [
{
"path": "myfolder/*.js",
"maxSize": "100kB"
}
]
}
}
[!NOTE] You can also use a
bundlewatch.config.jsfile instead of thepackage.jsonfield. See the documentation for more details.
npm run bundlewatch
This will give you command line output. If you want BundleWatch to report build status on your pull requests, see below.
BundleWatch can report its status on your GitHub Pull Requests.
BUNDLEWATCH_GITHUB_TOKENYou will need to give BundleWatch access to your GitHub Statuses, which can be done by heading to: https://service.bundlewatch.io/setup-github
This will give you your BUNDLEWATCH_GITHUB_TOKEN. You will need to set this as an environment variable in CI.
The most efficient way to get this running is to ensure that some environment variables are available for BundleWatch to find.
CI_REPO_OWNER github.com/facebook/reactCI_REPO_NAME github.com/facebook/reactCI_COMMIT_SHACI_BRANCHIf you're using, Travis, CircleCI, Wrecker, Drone or GitHub Actions these should all work out of the box.
[!TIP] Have a look at the source code to see which variables are automatically found:
getCIVars
After setting up the above you will have BuildStatus on your Pull Requests. Clicking the details link on the reported status will show you a results file breakdown.
Full documentation available on bundlewatch.io
Contributions of any kind are welcome! See the Contributing docs.