This vite plugin will stop your js chunks from becoming too big
It's the chunk that's loaded at the very beginning. If you do code splitting properly then page specific code should not be in here. Usually the bootstrap chunk will contain UI theme, fe analytics, app router, etc content
The size of this chunk has an impact of your page app's page load performance. Especially because it's the first js chunk to get fetched by the browser when a user visits your site.
- The built in config only prints a warning message whereas this plugin will fail the CI
- The built in config will apply the same chunk size limit to all chunks whereas this plugin lets you set a more strict limit on the bootstrap chunk
Add the following code in the plugins array of your vite config file. See vite plugin docs
enforceBootstrapBundleSize({
bootstrapChunkName: 'bootstrap',
maxBootstrapChunkSizeKb: 2000,
additionalInstructionsMsg: 'Please consult slack channel #team-xyz if you need help'
})
bootstrapChunkName
(optional, defaults tobootstrap
) Specify name of the bootstrap chunk.maxBootstrapChunkSizeKb
Bootstrap chunk size thresholdadditionalInstructionsMsg
Show additional help text when the threshold is crossed e.g. how to proceed, who to consult
- Make your changes & raise an MR
- Commit messages should conform to conventionalcommits format)
- Get approval & squash merge with a commeit message following the semantic-release convention
- Github actions will auto build & publish a new version of the package to npm
This repo is extended from ryansonshine/typescript-npm-package-template