Skip to content

Commit

Permalink
perf: build chunk split more fine-grained.
Browse files Browse the repository at this point in the history
consider pnpm node_modules special link to split chunks.
  • Loading branch information
riccox committed Mar 6, 2023
1 parent d39afe2 commit 958c4fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export default defineConfig({
manualChunks(id) {
// node_modules is mostly the main reason for the large chunk problem,
// With this you're telling Vite to treat the used modules separately.
// To understand better what it does, try to compare the logs from the build command with and without this change.
// To understand better what it does,
// try to compare the logs from the build command with and without this change.
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
const importStrArr = id.toString().split('node_modules/');
return importStrArr[importStrArr.length - 1].split('/')[0].toString();
}
},
},
Expand Down

0 comments on commit 958c4fd

Please sign in to comment.