I'm new to webpack and eperimenting with code splitting. I would like to create more than one custom chunks, thus using cacheGroups like this:
optimization: {
minimize: true,
splitChunks: {
cacheGroups: {
visuals: {
name: 'visuals',
chunks: 'all',
test: /[\\/]node_modules[\\/](swiper|@fancyapps\/ui|dom7|ssr-window)[\\/]/
},
lowdash: {
name: 'lowdash',
chunks: 'all',
test: /[\\/]node_modules[\\/]lodash[\\/]/
}
},
}
},
As you can see, on the first chunk, which is for swiper and fancybox, I'm adding also dom7 and ssr-window, which are swiper's dependencies. I was wondering: is there a way to tell webpack to follow all the package's dependencies? I mean, a way to tell webpack 'just pick swiper package and auto-include all its dependencies in the chunk, without he need to specifying them manually'?