Skip to content

Commit c86f7cb

Browse files
committed
chore(deps): update dependency kkt to v7.
Upgrade react-scripts to v5, Support Webpack 5.x kktjs/kkt#198
1 parent 1ca63a0 commit c86f7cb

File tree

2 files changed

+48
-121
lines changed

2 files changed

+48
-121
lines changed

.kktrc.ts

Lines changed: 39 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import rawModules from '@kkt/raw-modules';
66
import scopePluginOptions from '@kkt/scope-plugin-options';
77
import pkg from './package.json';
88

9-
export default (conf: Configuration, env: string, options: LoaderConfOptions) => {
9+
export default (conf: Configuration, env: 'production' | 'development', options: LoaderConfOptions) => {
1010
conf = lessModules(conf, env, options);
1111
conf = rawModules(conf, env, { ...options });
1212
conf = scopePluginOptions(conf, env, {
@@ -19,118 +19,46 @@ export default (conf: Configuration, env: string, options: LoaderConfOptions) =>
1919
conf.plugins!.push(new webpack.DefinePlugin({
2020
VERSION: JSON.stringify(pkg.version),
2121
}));
22-
conf.optimization = {
23-
...conf.optimization,
24-
splitChunks: {
25-
chunks: 'all', // async对异步引入的代码分割 initial 对同步引入代码分割 all对同步异步引入的分割都开启
26-
minSize: 30000, // 字节 引入的文件大于30kb才进行分割
27-
maxSize: 0, // 文件的最大尺寸,优先级:maxInitialRequest/maxAsyncRequests < maxSize < minSize,需要注意的是这个如果配置了,umi.js 就可能被拆开,最后构建出来的 chunkMap 中可能就找不到 umi.js 了
28-
minChunks: 1, // 模块至少使用次数
29-
maxAsyncRequests: 30, // 同时加载的模块数量最多是_个,只分割出同时引入的前_个文件(按需加载模块)
30-
maxInitialRequests: 25, // 首页加载的时候引入的文件最多 _ 个(加载初始页面)
31-
automaticNameDelimiter: '~', // 缓存组和生成文件名称之间的连接符
32-
name: true, // 缓存组里面的 filename 生效,覆盖默认命名
33-
cacheGroups: {
34-
markdown_preview: {
35-
name: 'vendors-markdown-preview',
36-
chunks: 'all',
37-
test: /[\\/]node_modules[\\/](@uiw\/react-markdown-preview|codemirror)[\\/]/,
38-
priority: -2,
39-
},
40-
prismjs: {
41-
name: 'vendors-prismjs',
42-
chunks: 'all',
43-
test: /[\\/]node_modules[\\/](prismjs)[\\/]/,
44-
priority: -2,
45-
},
46-
react_code_preview: {
47-
name: 'vendors-code-preview',
48-
chunks: 'all',
49-
test: /[\\/]node_modules[\\/](@uiw\/react-code-preview)[\\/]/,
50-
priority: -2,
51-
},
52-
react: {
53-
name: 'vendors-react',
54-
chunks: 'all',
55-
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/,
56-
priority: -5,
57-
},
58-
lodash: {
59-
name: 'vendors-lodash',
60-
chunks: 'all',
61-
test: /[\\/]node_modules[\\/](lodash)[\\/]/,
62-
priority: -5,
63-
},
64-
babel_plugin: {
65-
name: 'babel_plugin',
66-
chunks: 'all',
67-
// test: /[\\/]node_modules[\\/](babel-plugin-transform-remove-imports)[\\/]/,
68-
test: /[\\/]node_modules[\\/](babel-?.*)[\\/]/,
69-
priority: -5,
70-
},
71-
// babel_runtime: {
72-
// name: 'vendors-runtime',
73-
// chunks: 'all',
74-
// test: /[\\/]node_modules[\\/](@babel)[\\/]/,
75-
// priority: -5,
76-
// },
77-
babel_standalone: {
78-
name: 'vendors-standalone',
79-
chunks: 'all',
80-
test: /[\\/]node_modules[\\/](@babel\/standalone)[\\/]/,
81-
priority: -5,
82-
},
83-
babel_runtime_template: {
84-
name: 'vendors-runtime-template',
85-
chunks: 'all',
86-
test: /[\\/]node_modules[\\/]@babel[\/](template|regenerator|highlight|parser|code-frame|plugin-transform-classes)[\\/]/,
87-
priority: -5,
88-
},
89-
babel_runtime_core: {
90-
name: 'vendors-runtime-core',
91-
chunks: 'all',
92-
test: /[\\/]node_modules[\\/](@babel\/core)[\\/]/,
93-
priority: -5,
94-
},
95-
babel_remark: {
96-
name: 'vendors-remark',
97-
chunks: 'all',
98-
test: /[\\/]node_modules[\\/](remark-parse)[\\/]/,
99-
priority: -5,
100-
},
101-
babel_runtime_generator: {
102-
name: 'vendors-runtime-generator',
103-
chunks: 'all',
104-
test: /[\\/]node_modules[\\/](@babel\/generator)[\\/]/,
105-
priority: -5,
106-
},
107-
babel_helper: {
108-
name: 'vendors-helper',
109-
chunks: 'all',
110-
test: /[\\/]node_modules[\\/](@babel\/helper?.*)[\\/]/,
111-
priority: -5,
112-
},
113-
babel_runtime_helpers: {
114-
name: 'vendors-runtime-helpers',
115-
chunks: 'all',
116-
test: /[\\/]node_modules[\\/](@babel\/runtime\/helpers)[\\/]/,
117-
priority: -5,
118-
},
119-
babel_runtime_types: {
120-
name: 'vendors-runtime-types',
121-
chunks: 'all',
122-
test: /[\\/]node_modules[\\/](@babel\/types)[\\/]/,
123-
priority: -5,
124-
},
125-
babel_runtime_traverse: {
126-
name: 'vendors-runtime-traverse',
127-
chunks: 'all',
128-
test: /[\\/]node_modules[\\/](@babel\/traverse)[\\/]/,
129-
priority: -5,
22+
if (env === 'production') {
23+
conf.output = { ...conf.output, publicPath: './' };
24+
conf.optimization = {
25+
...conf.optimization,
26+
splitChunks: {
27+
cacheGroups: {
28+
reactvendor: {
29+
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
30+
name: 'react-vendor',
31+
chunks: 'all',
32+
},
33+
babelstandalone: {
34+
test: /[\\/]node_modules[\\/](@babel[\\/]standalone)[\\/]/,
35+
name: 'babel-standalone-vendor',
36+
chunks: 'all',
37+
},
38+
prismjs: {
39+
test: /[\\/]node_modules[\\/](refractor)[\\/]/,
40+
name: 'refractor-vendor',
41+
chunks: 'all',
42+
},
43+
codemirror: {
44+
test: /[\\/]node_modules[\\/](@codemirror)[\\/]/,
45+
name: 'codemirror-vendor',
46+
chunks: 'all',
47+
},
48+
uiw: {
49+
test: /[\\/]node_modules[\\/](@uiw)[\\/]/,
50+
name: 'uiw-vendor',
51+
chunks: 'all',
52+
},
53+
parse5: {
54+
test: /[\\/]node_modules[\\/](parse5)[\\/]/,
55+
name: 'parse5-vendor',
56+
chunks: 'all',
57+
},
13058
},
13159
},
132-
},
133-
};
60+
};
61+
}
13462

13563
return conf;
13664
}

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@
3333
"react-dom": ">=16.8.0"
3434
},
3535
"devDependencies": {
36-
"@kkt/less-modules": "6.11.0",
37-
"@kkt/raw-modules": "6.11.0",
38-
"@kkt/scope-plugin-options": "6.11.0",
39-
"@types/react": "17.0.21",
40-
"@types/react-dom": "17.0.9",
41-
"@uiw/react-code-preview": "2.1.0",
36+
"@kkt/less-modules": "7.0.5",
37+
"@kkt/raw-modules": "7.0.5",
38+
"@kkt/scope-plugin-options": "7.0.5",
39+
"@types/react": "17.0.38",
40+
"@types/react-dom": "17.0.11",
41+
"@uiw/react-code-preview": "3.0.0",
4242
"@uiw/react-github-corners": "1.5.3",
4343
"@uiw/react-markdown-preview": "3.3.2",
4444
"@uiw/reset.css": "1.0.5",
45-
"compile-less-cli": "1.8.8",
46-
"kkt": "6.11.0",
47-
"rehype-attr": "2.0.2",
45+
"compile-less-cli": "1.8.11",
46+
"kkt": "7.0.5",
4847
"react": "17.0.2",
4948
"react-dom": "17.0.2",
50-
"tsbb": "3.2.1",
49+
"tsbb": "3.5.4",
5150
"uiw": "4.9.7"
5251
},
5352
"eslintConfig": {

0 commit comments

Comments
 (0)