react-ssr-template
react-ssr-template copied to clipboard
QUESTION: route based package chunking
hi,
The project is great, and I want to thank you first.
I'm working on a performance-focused project, and I want to chunk and separate route-based packages.
vendor: {
test: /[\\/]node_modules[\\/]/,
enforce: true,
chunks: 'all',
name(module: any) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
switch (packageName) {
case 'react':
case 'react-dom':
case 'scheduler':
case 'object-assign':
return 'react';
case 'path-to-regexp':
case 'uuid':
return 'rarely';
default:
return 'vendor';
}
},
},
I want to separate them like the structure here, such as homeVendor, usersVendor, etc., and load only that vendor on the relevant page. Separating them is not a problem, but how can I decide which vendor to load on which route? Is it possible to do something like this?