I am currently experimenting with code splitting in Webback4.
I'd like to put every external package (from node_modules) into its own chunk. Can someone please provide me a hint how to do it?
This is how far I got so far (except from webpack.config.js)
optimization: {
runtimeChunk: {
name: "runtime"
},
splitChunks: {
chunks: "all",
name(module) {
return module.resource && module.resource.replace(/\//g, "_");
}
}
}
But now, every single JS file is a separate chunk. So, I'd like to do it per package.
Ideally, the filename should be of form:
<package-name>-<version>.js
for example:
protobufjs-6.1.3.js
Help?
Bonus: could I also somehow generate content hash for the filename?