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

35 lines
680 B
JavaScript
Raw Normal View History

2016-01-04 11:07:08 +08:00
var path = require("path");
module.exports = {
// mode: "development" || "production",
2016-01-04 11:07:08 +08:00
entry: {
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
},
optimization: {
2018-12-19 21:05:17 +08:00
chunkIds: "named",
splitChunks: {
cacheGroups: {
2018-01-22 22:18:41 +08:00
commons: {
chunks: "initial",
minChunks: 2,
2018-02-17 20:35:06 +08:00
maxInitialRequests: 5, // The default limit is too small to showcase the effect
2018-01-22 22:18:41 +08:00
minSize: 0 // This is example is too small to create commons chunks
},
vendor: {
test: /node_modules/,
2018-01-22 22:18:41 +08:00
chunks: "initial",
name: "vendor",
2018-02-17 20:35:06 +08:00
priority: 10,
enforce: true
}
}
}
2016-01-04 11:07:08 +08:00
},
output: {
path: path.join(__dirname, "dist"),
2016-01-04 11:07:08 +08:00
filename: "[name].js"
}
2016-01-04 11:07:08 +08:00
};