Skip to content

Commit 371dd09

Browse files
committed
better chunk config
1 parent 02d55c8 commit 371dd09

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

vite.config.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,24 @@ export default defineConfig(({ mode }) => ({
104104
rolldownOptions: {
105105
// default entrypoint for vite is '<root>/index.html', so we don't have to set it
106106
output: {
107-
// React Router automatically splits any route module into its own file,
108-
// but some end up being like 300 bytes. It feels silly to have several
109-
// hundred of those, so we set a minimum size to end up with fewer.
110-
// https://rolldown.rs/in-depth/advanced-chunks
107+
// Merge tiny shared chunks to reduce the number of requests.
108+
// Rolldown has this instead of Rollup's experimentalMinChunkSize;
109+
// https://github.com/rolldown/rolldown/issues/4788
111110
codeSplitting: {
112-
groups: [{ name: 'small-chunks', minSize: 30 * KiB }],
111+
groups: [
112+
{
113+
name: 'vendor',
114+
test: /\/node_modules\//,
115+
minSize: 4096,
116+
maxSize: 1000 * 1000,
117+
},
118+
{
119+
name: 'shared',
120+
minSize: 4096,
121+
maxSize: 1000 * 1000,
122+
minShareCount: 2,
123+
},
124+
],
113125
},
114126
},
115127
},

0 commit comments

Comments
 (0)