公共代码提取功能是针对多入口文件的;
背景:在pageA.js和pageB.js中分别引用subPageA.js和subPageB.js
webpack.config.js文件:
1 var path = require(‘path‘) 2 module.exports = { 3 entry:{ 4 pageA:‘./src/pageA.js‘, 5 pageB:‘./src/pageB.js‘ 6 }, 7 output: { 8 filename: "[name].js", 9 path:path.resolve(__dirname,‘./dist‘) 10 }, 11 optimization: { 12 splitChunks:{ 13 cacheGroups: { 14 vender:{ 15 test:/node_modules/, 16 chunks:‘initial‘, 17 name:‘vender‘, 18 priority:10 19 }, 20 utils:{ 21 chunks:‘initial‘, 22 name:‘utils‘, 23 minSize:0 24 } 25 } 26 } 27 } 28 }
原文地址:https://www.cnblogs.com/yangguoe/p/9882266.html
时间: 2024-09-30 20:55:09