split-vendor-chunk-plugin
v7.0.0
Published
Vite plugin to split vendor chunks
Maintainers
Readme
Vite Split Vendor Chunk Plugin
A Vite plugin that automatically splits vendor chunks from node_modules into separate files. This helps optimize your build by:
- Improving caching efficiency
- Reducing main bundle size
- Enabling parallel loading of dependencies
Installation
npm install split-vendor-chunk-plugin --save-devUsage
In your vite.config.js:
import splitVendorChunkPlugin from 'split-vendor-chunk-plugin'
export default {
plugins: [
splitVendorChunkPlugin()
]
}How it works
The plugin automatically detects imports from node_modules and splits them into separate chunks:
- Regular packages:
node_modules/lodash→lodash-<hash>.js - Scoped packages:
node_modules/@babel/core→@babel/core-<hash>.js - Other node_modules: grouped into
vendor-<hash>.js
License
MIT © Roger Vilà
