A monorepo containing CLI tool for validating minified bundle content and related packages.
All packages in this repo are published under @bundle-validator
scope. For example, @bundle-validator/cli
or @bundle-validator/plugin-bundle-size
First, install bundle validator either globally:
npm install -g @bundle-validator/cli
or add it to your project as a devDependency:
npm install --save-dev @bundle-validator/cli
Second, create a configuration. Bundle validator will start to search in your current directory and up the directory tree for the following:
- a
bv
property in package.json - a
.bvrc
file in JSON or YAML format - a
.bvrc.json
,.bvrc.yaml
,.bvrc.yml
,.bvrc.js
, or.bvrc.cjs
file - a
bv.config.js
orbv.config.cjs
CommonJS module exporting an object
And last, run the tool's check
subcommand, providing glob patterns for finding files tool will validate and using -c, --config
command line argument to specify a path to the configuration file, i.e.:
bv check --config "./tools/.bvrc.json" "./dist/*.js"
See examples section for more usage examples.
Configuration has only one required option - plugins
. By that option one should specify which plugins tool should use to validate provided set of files.
For example:
{
"plugins": [
[
"@bundle-validator/plugin-bundle-size",
{
"maxSize": "128 KB"
}
],
"@bundle-validator/plugin-no-ie11"
]
}
Here, we specified 2 plugins - @bundle-validator/plugin-bundle-size
and @bundle-validator/plugin-no-ie11
. Some plugins may require options, in this example we provided maxSize
option for @bundle-validator/plugin-bundle-size
and no options for @bundle-validator/plugin-no-ie11
.
Plugins are regular packages and should be installed from NPM. Official plugins are published under @bundle-validator
scope.
To customize tool output, one can specify the name of reporter and, optional configuration for reporter using reporterOptions
option. All mocha reporters are supported. Tool uses spec reporter by default.
For example:
{
"reporter": "tap",
"plugins": ["@bundle-validator/plugin-no-ie11"]
}
$ npm install -g @bundle-validator/cli
$ LOG_LEVEL=debug bv check "./dist/*.js" "./output/**/*.min.js"
$ npm install -g @bundle-validator/cli
$ LOG_LEVEL=debug bv check --config ./tools/bv.config.js "./dist/*.js"
See our Contributing Guide.
If you want to create a new plugin, please go through Plugins.
- Amy Zhao