webpack/examples/common-chunk-and-vendor-chunk/webpack.config.js

34 lines
659 B
JavaScript

var path = require("path");
module.exports = {
// mode: "development" || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
chunks: "initial",
minChunks: 2,
maxInitialRequests: 5, // The default limit is too small to showcase the effect
minSize: 0 // This is example is too small to create commons chunks
},
vendor: {
test: /node_modules/,
chunks: "initial",
name: "vendor",
priority: 10,
enforce: true
}
}
}
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js"
}
};