Repository navigation
Split entry vendor modules into separate chunk #5554
Replies: 1 comment
|
The deprecated Use the function form so you control the grouping: // vite.config.js
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
// single shared vendor chunk (closest to the old plugin)
return 'vendor';
}
}
}
}
}If that single manualChunks(id) {
if (id.includes('node_modules')) {
const parts = id.split('node_modules/')[1].split('/');
const pkg = parts[0].startsWith('@') ? `${parts[0]}/${parts[1]}` : parts[0];
return `vendor-${pkg}`;
}
}Two things that bite here: |
Uh oh!
There was an error while loading. Please reload this page.
I'm using vite and trying to mimic their deprecated splitVendorChunkPlugin but with manualChunks/entryFileNames/chunkFileNames configuration properly. I seem to only be able to split every single vendor into a separate chunk, or combine every vendor into a single chunk - the latter leads to a lot of unused javascript on initial page load. splitVendorChunkPlugin properly took the entry chunk and split out the vendor modules from it to its own chunk. Since it is deprecated, I've been struggling to figure out how to do this with manualChunks, entryFileNames, or chunkFileNames.
All reactions