Skip to content

Commit 743b338

Browse files
committed
fix: Fix #94
1 parent db05706 commit 743b338

File tree

1 file changed

+70
-50
lines changed

1 file changed

+70
-50
lines changed

.kktrc.ts

+70-50
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,76 @@ export default (conf: Configuration, env: 'production' | 'development', options:
2121
VERSION: JSON.stringify(pkg.version),
2222
}));
2323

24-
// conf.optimization = {
25-
// ...conf.optimization,
26-
// splitChunks: {
27-
// chunks: 'all', // async对异步引入的代码分割 initial 对同步引入代码分割 all对同步异步引入的分割都开启
28-
// minSize: 30000, // 字节 引入的文件大于30kb才进行分割
29-
// maxSize: 0, // 文件的最大尺寸,优先级:maxInitialRequest/maxAsyncRequests < maxSize < minSize,需要注意的是这个如果配置了,umi.js 就可能被拆开,最后构建出来的 chunkMap 中可能就找不到 umi.js 了
30-
// minChunks: 1, // 模块至少使用次数
31-
// maxAsyncRequests: 30, // 同时加载的模块数量最多是_个,只分割出同时引入的前_个文件(按需加载模块)
32-
// maxInitialRequests: 25, // 首页加载的时候引入的文件最多 _ 个(加载初始页面)
33-
// automaticNameDelimiter: '~', // 缓存组和生成文件名称之间的连接符
34-
// name: true, // 缓存组里面的 filename 生效,覆盖默认命名
35-
// cacheGroups: {
36-
// markdown_preview: {
37-
// name: 'vendors-markdown-preview',
38-
// chunks: 'all',
39-
// test: /[\\/]node_modules[\\/](@uiw\/react-markdown-preview|codemirror)[\\/]/,
40-
// priority: -2,
41-
// },
42-
// uiwjs: {
43-
// name: 'vendors-uiwjs',
44-
// chunks: 'all',
45-
// test: /[\\/]node_modules[\\/]@uiw\/(copy-to-clipboard|formatter|icons|react-affix|react-alert|react-avatar|react-back-top|react-badge|react-breadcrumb|react-button|react-button-group|react-calendar|react-card|react-checkbox|react-codemirror|react-collapse|react-copy-to-clipboard|react-date-input|react-date-picker|react-descriptions|react-divider|react-drawer|react-dropdown|react-file-input|react-form|react-github-corners|react-grid|react-icon|react-input|react-layout|react-list|react-loader|react-menu|react-message|react-modal|react-month-picker|react-notify|react-overlay|react-overlay-trigger|react-pagination|react-pin-code|react-popover|react-portal|react-progress|react-radio|react-rate|react-search-select|react-select|react-slider|react-split|react-steps|react-switch|react-table|react-tabs|react-tag|react-textarea|react-time-picker|react-tooltip|react-tree|react-tree-checked|reset.css|utils)[\\/]/,
46-
// priority: -4, // 优先级,先打包到哪个组里面,值越大,优先级越高
47-
// },
48-
// react: {
49-
// name: 'vendors-react',
50-
// chunks: 'all',
51-
// test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
52-
// priority: -5,
53-
// },
54-
// babel_standalone: {
55-
// name: 'vendors-standalone',
56-
// chunks: 'all',
57-
// test: /[\\/]node_modules[\\/](@babel\/standalone)[\\/]/,
58-
// priority: -5,
59-
// },
60-
// prismjs: {
61-
// test: /[\\/]node_modules[\\/](prismjs)[\\/]/,
62-
// name: 'prismjs-vendor',
63-
// chunks: 'async',
64-
// },
65-
// babel_runtime: {
66-
// name: 'vendors-runtime',
67-
// chunks: 'all',
68-
// test: /[\\/]node_modules[\\/](@babel\/runtime|@babel\/plugin-transform-classes|babel-plugin-transform-remove-imports)[\\/]/,
69-
// priority: -5,
70-
// },
71-
// }
72-
// }
73-
// }
24+
conf.module!.exprContextCritical = false;
25+
26+
conf.optimization = {
27+
...conf.optimization,
28+
splitChunks: {
29+
chunks: 'all', // async对异步引入的代码分割 initial 对同步引入代码分割 all对同步异步引入的分割都开启
30+
minSize: 30000, // 字节 引入的文件大于30kb才进行分割
31+
maxSize: 0, // 文件的最大尺寸,优先级:maxInitialRequest/maxAsyncRequests < maxSize < minSize,需要注意的是这个如果配置了,umi.js 就可能被拆开,最后构建出来的 chunkMap 中可能就找不到 umi.js 了
32+
minChunks: 1, // 模块至少使用次数
33+
maxAsyncRequests: 30, // 同时加载的模块数量最多是_个,只分割出同时引入的前_个文件(按需加载模块)
34+
maxInitialRequests: 25, // 首页加载的时候引入的文件最多 _ 个(加载初始页面)
35+
automaticNameDelimiter: '~', // 缓存组和生成文件名称之间的连接符
36+
name: true, // 缓存组里面的 filename 生效,覆盖默认命名
37+
cacheGroups: {
38+
markdown_preview: {
39+
name: 'vendors-markdown-preview',
40+
chunks: 'all',
41+
test: /[\\/]node_modules[\\/](@uiw\/react-markdown-preview)[\\/]/,
42+
priority: -2,
43+
},
44+
codemirror: {
45+
name: 'vendors-codemirror',
46+
chunks: 'all',
47+
test: /[\\/]node_modules[\\/](@codemirror)[\\/]/,
48+
priority: -2,
49+
},
50+
refractor: {
51+
name: 'vendors-refractor',
52+
chunks: 'all',
53+
test: /[\\/]node_modules[\\/](refractor)[\\/]/,
54+
priority: -2,
55+
},
56+
uiwjs: {
57+
name: 'vendors-uiwjs',
58+
chunks: 'all',
59+
test: /[\\/]node_modules[\\/]@uiw\/(copy-to-clipboard|formatter|icons|react-affix|react-alert|react-avatar|react-back-top|react-badge|react-breadcrumb|react-button|react-button-group|react-calendar|react-card|react-checkbox|react-codemirror|react-collapse|react-copy-to-clipboard|react-date-input|react-date-picker|react-descriptions|react-divider|react-drawer|react-dropdown|react-file-input|react-form|react-github-corners|react-grid|react-icon|react-input|react-layout|react-list|react-loader|react-menu|react-message|react-modal|react-month-picker|react-notify|react-overlay|react-overlay-trigger|react-pagination|react-pin-code|react-popover|react-portal|react-progress|react-radio|react-rate|react-search-select|react-select|react-slider|react-split|react-steps|react-switch|react-table|react-tabs|react-tag|react-textarea|react-time-picker|react-tooltip|react-tree|react-tree-checked|reset.css|utils)[\\/]/,
60+
priority: -4, // 优先级,先打包到哪个组里面,值越大,优先级越高
61+
},
62+
react: {
63+
name: 'vendors-react',
64+
chunks: 'all',
65+
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
66+
priority: -5,
67+
},
68+
babel_standalone: {
69+
name: 'vendors-standalone',
70+
chunks: 'all',
71+
test: /[\\/]node_modules[\\/](@babel\/standalone)[\\/]/,
72+
priority: -2,
73+
},
74+
babel_vendors: {
75+
name: 'babel_vendors',
76+
chunks: 'all',
77+
test: /[\\/]node_modules[\\/](@babel)[\\/]/,
78+
priority: -5,
79+
},
80+
prismjs: {
81+
test: /[\\/]node_modules[\\/](prismjs)[\\/]/,
82+
name: 'prismjs-vendor',
83+
chunks: 'async',
84+
},
85+
babel_runtime: {
86+
name: 'vendors-runtime',
87+
chunks: 'all',
88+
test: /[\\/]node_modules[\\/](@babel\/runtime|@babel\/plugin-transform-classes|babel-plugin-transform-remove-imports)[\\/]/,
89+
priority: -5,
90+
},
91+
}
92+
}
93+
}
7494

7595
if (env === 'production') {
7696
conf.output = { ...conf.output, publicPath: './' };

0 commit comments

Comments
 (0)