Try a different code-splitting tactic

This commit is contained in:
Alex Gleason committed 2025-09-16 00:07:30 -05:00
1 parent 753c12bcac
commit 94d14a87aa
1 file changed
+22
+22
View File
@@ -12,6 +12,28 @@ export default defineConfig(() => ({
plugins: [
react(),
],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
// get the path after "node_modules/"
const parts = id.toString().split('node_modules/')[1].split('/');
// handle scoped packages (@scope/name)
const pkgName = parts[0].startsWith('@')
? `${parts[0]}/${parts[1]}`
: parts[0];
return `npm/${pkgName.replace('@', '')}`;
}
if (id.includes('/src/')) {
return 'app';
}
},
},
},
},
test: {
globals: true,
environment: 'jsdom',