vite-plugin-anti-chonk
v2.0.0
Published
A template for creating npm packages using TypeScript and VSCode
Downloads
1,968
Readme
About
This vite plugin will stop your js chunks from becoming too big
FAQ
What is the Bootstrap Chunk?
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
Why Should we enforce size limit on the bootstrap chunk?
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.
Does not vite have built in Chunk size limiting capability?
- 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
Usage
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'
})
Configuration
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
Links
How to contribute
- 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
Template
This repo is extended from ryansonshine/typescript-npm-package-template