Skip to content

Commit 1964706

Browse files
'路由懒加载分包'
1 parent 3317bec commit 1964706

3 files changed

Lines changed: 32 additions & 39 deletions

File tree

src/router/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: Jason chen
55
* @Date: 2020-06-26 17:46:26
66
* @LastEditors: sueRimn
7-
* @LastEditTime: 2021-08-16 17:03:46
7+
* @LastEditTime: 2021-08-17 11:23:34
88
*/
99
// 导入 vue-router
1010
import Vue from 'vue';
@@ -21,11 +21,11 @@ const router = new VueRouter({
2121
routes: [
2222
{
2323
path: '/',
24-
component: () => import(/*webpackChunkName: "my-customToolbar-chunk"*/ "../views/customToolbar/customToolbar.vue"),
24+
component: () => import("../views/customToolbar/customToolbar.vue"),
2525
},
2626
{
2727
path: "/customToolbar",
28-
component: () => import(/*webpackChunkName: "my-customToolbar-chunk"*/ "../views/customToolbar/customToolbar.vue")
28+
component: () => import("../views/customToolbar/customToolbar.vue")
2929
},
3030
{
3131
path: "/renderModel",

test.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

vue.config.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,35 @@ module.exports = {
2525
}),
2626
],
2727
optimization: {
28-
splitChunks: {
29-
chunks: "all",
30-
name: false,
31-
minSize: 0,
32-
cacheGroups: {
33-
commons: {
34-
minChunks: 2,//表示被引用次数,默认为1;
35-
maxInitialRequests: 5, //最大的初始化加载次数,默认为 3;
36-
minSize: 0, // 模块的文件体积超过 0 byte就抽取到common中
37-
name: 'chunk-commons',//抽取出来文件的名字,默认为 true,表示自动生成文件名
38-
},
39-
elementUI: {
40-
name: "chunk-element-ui", // 单独将 elementUI 拆包
41-
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
42-
test: /[\\/]node_modules[\\/]element-ui[\\/]/,
43-
},
44-
mxgraph: {
45-
name: "chunk-mxgraph", // 单独将 elementUI 拆包
46-
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
47-
test: /[\\/]node_modules[\\/]mxgraph[\\/]/,
48-
},
49-
}
50-
},
28+
// splitChunks: {
29+
// chunks: "all",
30+
// cacheGroups: {
31+
// common: {
32+
// name: 'chunk-common',
33+
// test: /[\\/]node_modules[\\/]/,
34+
// priority: 10,
35+
// minChunks: 1,
36+
// chunks: 'all',
37+
// },
38+
// elementUI: {
39+
// name: "chunk-element-ui", // 单独将 elementUI 拆包
40+
// priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
41+
// test: /[\\/]node_modules[\\/]element-ui[\\/]/,
42+
// },
43+
// mxgraph: {
44+
// name: "chunk-mxgraph", // 单独将 elementUI 拆包
45+
// priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
46+
// test: /[\\/]node_modules[\\/]mxgraph[\\/]/,
47+
// },
48+
// component: {
49+
// name: 'chunk-componentaa',
50+
// test: /[\\/]src[\\/]/,
51+
// priority: 50,
52+
// minChunks: 1,
53+
// chunks: 'all',
54+
// },
55+
// }
56+
// },
5157
minimizer: [new UglifyJsPlugin(
5258
{
5359
uglifyOptions: {

0 commit comments

Comments
 (0)