Skip to content

Commit

Permalink
docs(plugins): Add custom vendor chunks using RegEx example (#2518)
Browse files Browse the repository at this point in the history
* docs(config): Example 3 - custom vendor chunk using RegEx

* docs(config): Example 3 SplitChunks Fenced blank added

* docs(config): (typo) Example 3 - custom vendor chunk using RegEx

* sakhisheikh
docs(config): (reworded) Example 3 - custom vendor chunk using RegEx

* docs(config): (Reword) Example 3 - custom vendor chunk using RegEx

* docs(config): (Reword) Example 3 - custom vendor chunk using RegEx
  • Loading branch information
sakhisheikh authored and montogeek committed Sep 18, 2018
1 parent b9c586f commit 9e959d2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/content/plugins/split-chunks-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ contributors:
- EugeneHlushko
- byzyk
- madhavarshney
- sakhisheikh
related:
- title: webpack's automatic deduplication algorithm example
url: https://github.com/webpack/webpack/blob/master/examples/many-pages/README.md
Expand Down Expand Up @@ -344,3 +345,28 @@ module.exports = {
```

W> This might result in a large chunk containing all external packages. It is recommended to only include your core frameworks and utilities and dynamically load the rest of the dependencies.

### Split Chunks: Example 3

Create a `custom vendor` chunk, which contains certain `node_modules` packages matched by `RegExp`.

__webpack.config.js__

```js
module.exports = {
//...
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'vendor',
chunks: 'all',
}
}
}
}
};
```

T> This will result in splitting `react` and `react-dom` into a separate chunk. If you're not sure what packages have been included in a chunk you may refer to [Bundle Analysis](/guides/code-splitting/#bundle-analysis) section for details.

0 comments on commit 9e959d2

Please sign in to comment.