config.optimization.runtimeChunk('single') ⑥splitChunks 如果使用了某些长期不会改变的库,像element-ui ,打包完成有 600 多 KB ,包含在默认 vendor 中显然不合适,每次用户都要加载这么大的文件体验不好,所以要单独打包: config.optimization.splitChunks({ chunks:'all',cacheGroups: {//cacheGroups下可以可以配置...
// `runtime` must same as runtimeChunk name. default is `runtime` inline: /runtime\..*\.js$/ }]) .end() config .optimization.splitChunks({ chunks: 'all', cacheGroups: { libs: { name: 'chunk-libs', test: /[\\/]node_modules[\\/]/, priority: 10, chunks: 'initial' // onl...
// 将 runtime 作为内联引入不单独存在 inline: /runtime\..*\.js$/ } ]) .end() config.optimization.splitChunks({ chunks: 'all', cacheGroups: { // cacheGroups 下可以可以配置多个组,每个组根据test设置条件,符合test条件的模块 commons: { name: 'chunk-commons', test: resolve('src/components')...
// `runtime` must same as runtimeChunk name. default is `runtime` inline: /runtime\..*\.js$/ } ]) .end(); config.optimization.splitChunks({ chunks: "all", cacheGroups: { libs: { name: "chunk-libs", test: /[\\/]node_modules[\\/]/, priority: 10, chunks: "initial" // o...
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm }, ECharts: { name: 'chunk-ECharts', priority: 20, test: /[\\/]node_modules[\\/]_?echarts(.*)/ // in order to adapt to cnpm } } }) // config.optimization.runtimeChunk('single') } }...
configureWebpack:config=>{// if (isProduction) {// 开启分离jsconfig.optimization={// runtimeChunk: 'single',splitChunks:{chunks:'all',maxInitialRequests:Infinity,maxSize:100000,//1000是1kbcacheGroups:{vendor:{test:/[\\/]node_modules[\\/]/,name(module){// get the name. E.g. node_mod...
解释webpack.optimize.CommonsChunkPlugin已被移除的情况: 在Webpack的较新版本中,webpack.optimize.CommonsChunkPlugin已被官方废弃并移除,因为它已经被集成到Webpack的内部优化机制中,特别是通过config.optimization选项来更灵活和强大地处理代码分割和公共代码提取。 引入新的替代方案config.optimization: 在Webpack 4及更...
config.optimization={ splitChunks: { cacheGroups: { vendors: { name: 'vendor', } } } } Asset Size Chunks Chunk Names app.e8019b78.js 73.7 KiB 0 [emitted] [immutable] app bg.jpg 82.6 KiB [emitted] index.html 303 bytes [emitted] styles.3ae8a7d8.css 5.31 KiB 0 [emitted] app ...
optimization:{runtimeChunk:'single',splitChunks:{chunks:'all',maxInitialRequests:Infinity,minSize:0,cacheGroups:{vendor:{test:/[\\/]node_modules[\\/]/,name(module){// get the name. E.g. node_modules/packageName/not/this/part.js// or node_modules/packageNameconstpackageName=module.context...
config.optimization={ splitChunks: { cacheGroups: { vendors: { name: 'vendor', } } } } Asset Size Chunks Chunk Names app.e8019b78.js 73.7 KiB 0 [emitted] [immutable] app bg.jpg 82.6 KiB [emitted] index.html 303 bytes [emitted] styles.3ae8a7d8.css 5.31 KiB 0 [emitted] app ...