From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Optimize with SplitChunks

Optimize with SplitChunks

From the course: Learning webpack 4

Start my 1-month free trial

Optimize with SplitChunks

- [Instructor] To take the optimizations one step further we can use the split chunks optimization. So first I'm going to add a key here to our webpack config called optimization. We're going to add a key called split chunks. And another key called chunks and we'll say all. Now what this is going to do is it's going to look for any repeated code between my two bundles and it's going to create a vendor bundle for that. So both of these, let's see both of these about and contact have react and react on. So webpack is going to create a bundle just for that vendor code. Let's run it. Npm run build. And we should see that we've created a bundle for about, for contact. And then we also have this vendors bundle that is much, much bigger. And that has all of the code that we've imported from react and react on. So this is a really useful thing if you're using a lot of libraries. You can use webpack to branch that out into its own thing, to minimize repeating of code and to just make things…

Contents