Reputation: 26182
How to just have everything that is loaded from node_modules in the separate bundle? What plugin or standard config should I use for this?
Upvotes: 0
Views: 98
Reputation: 427
You can use the CommonsChunkPlugin
, there is an example showing exactly this in their docs, (second example on this section):
https://webpack.js.org/plugins/commons-chunk-plugin/#passing-the-minchunks-property-a-function
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
minChunks: function (module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf("node_modules") !== -1;
}
})
Upvotes: 1