Vendor and Common Chunk Splitting
What you'll learn: How to isolate third-party dependencies into separate chunks that browsers can cache independently from your frequently-changing app code.
The Core Problem
Your app code changes often—bug fixes, new features, tweaks. But your third-party libraries (React, lodash, date-fns) change rarely. If everything bundles together, users must re-download the entire bundle for every tiny app update, even though the vendor code stayed identical.
How Vendor Splitting Works
Vendor chunk splitting separates your node_modules dependencies into their own bundle file. Think of it like organizing a moving truck: put stable furniture (vendor code) in one container and frequently-rearranged items (app code) in another. When you only rearrange items, you don't need to reload the furniture container.
When configured properly, your build outputs something like:
vendor.abc123.js— React, libraries (large, rarely changes)main.def456.js— Your app logic (smaller, changes often)
Browsers cache vendor.abc123.js aggressively. On your next deployment, only main.xyz789.js changes; users reuse the cached vendor bundle.
Common Chunks
Common chunk splitting goes further: extracting code shared across multiple routes into a separate bundle. If your /dashboard and /profile both import a shared UserCard component, that component moves into common.js instead of duplicating it in both route chunks.
This reduces redundancy and improves overall cache efficiency across navigation.
Configuration Context
Webpack's splitChunks optimization (configured in webpack.config.js) automatically handles this. By setting cacheGroups with test: /node_modules/, you instruct the bundler to isolate vendor code.
Key Takeaway: Vendor and common chunk splitting separates stable dependencies and shared code into independently-cacheable bundles, dramatically reducing re-download costs when your app code changes.