Skip to content

FlashcardNot attempted

A vendor chunk

Recall it before you reveal

Why put libraries like react and react-dom into their own chunk, and what is the trade-off?

Space to reveal
Show answer & explanation

Libraries change far less often than your code. In a separate chunk, their file name (hash) stays the same across deploys that only touch your code, so returning users keep them cached.

Vite doesn't create a vendor chunk by default; you opt in with build.rollupOptions.output.manualChunks (webpack: optimization.splitChunks).

Trade-offs: one big vendor chunk changes whenever any dependency is upgraded, and it may include libraries a page never uses. Splitting it into many chunks means more requests. Group by how often things change and where they're used.