Skip to content

Commit

Permalink
chore(deps): update dependency kkt to v7.
Browse files Browse the repository at this point in the history
Upgrade react-scripts to v5, Support Webpack 5.x
kktjs/kkt#198
  • Loading branch information
jaywcjlove committed Jan 8, 2022
1 parent c31c5a8 commit 12685e4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 120 deletions.
149 changes: 37 additions & 112 deletions website/.kktrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,120 +20,45 @@ export default (conf: Configuration, env: 'production' | 'development', options:
}),
);
conf.module!.exprContextCritical = false;
conf.optimization = {
...conf.optimization,
splitChunks: {
chunks: 'all', // async对异步引入的代码分割 initial 对同步引入代码分割 all对同步异步引入的分割都开启
minSize: 30000, // 字节 引入的文件大于30kb才进行分割
maxSize: 0, // 文件的最大尺寸,优先级:maxInitialRequest/maxAsyncRequests < maxSize < minSize,需要注意的是这个如果配置了,umi.js 就可能被拆开,最后构建出来的 chunkMap 中可能就找不到 umi.js 了
minChunks: 1, // 模块至少使用次数
maxAsyncRequests: 30, // 同时加载的模块数量最多是_个,只分割出同时引入的前_个文件(按需加载模块)
maxInitialRequests: 25, // 首页加载的时候引入的文件最多 _ 个(加载初始页面)
automaticNameDelimiter: '~', // 缓存组和生成文件名称之间的连接符
name: true, // 缓存组里面的 filename 生效,覆盖默认命名
cacheGroups: {
markdown_preview: {
name: 'vendors-markdown-preview',
chunks: 'all',
test: /[\\/]node_modules[\\/](@uiw\/react-markdown-preview|codemirror)[\\/]/,
priority: -2,
},
prismjs: {
test: /[\\/]node_modules[\\/](prismjs)[\\/]/,
name: 'prismjs-vendor',
chunks: 'async',
},
react_code_preview: {
name: 'vendors-code-preview',
chunks: 'all',
test: /[\\/]node_modules[\\/](@uiw\/react-code-preview)[\\/]/,
priority: -2,
},
react: {
name: 'vendors-react',
chunks: 'all',
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/,
priority: -5,
},
uiwjs: {
name: 'vendors-uiwjs',
chunks: 'all',
test: /[\\/]node_modules[\\/]@uiw\/(copy-to-clipboard|react-split)[\\/]/,
priority: -5,
},
lodash: {
name: 'vendors-lodash',
chunks: 'all',
test: /[\\/]node_modules[\\/](lodash)[\\/]/,
priority: -5,
},
babel_plugin: {
name: 'babel_plugin',
chunks: 'all',
// test: /[\\/]node_modules[\\/](babel-plugin-transform-remove-imports)[\\/]/,
test: /[\\/]node_modules[\\/](babel-?.*)[\\/]/,
priority: -5,
},
// babel_runtime: {
// name: 'vendors-runtime',
// chunks: 'all',
// test: /[\\/]node_modules[\\/](@babel)[\\/]/,
// priority: -5,
// },
babel_standalone: {
name: 'vendors-standalone',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/standalone)[\\/]/,
priority: -5,
},
babel_runtime_template: {
name: 'vendors-runtime-template',
chunks: 'all',
test: /[\\/]node_modules[\\/]@babel[\/](template|regenerator|highlight|parser|code-frame|plugin-transform-classes)[\\/]/,
priority: -5,
},
babel_runtime_core: {
name: 'vendors-runtime-core',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/core)[\\/]/,
priority: -5,
},
babel_runtime_generator: {
name: 'vendors-runtime-generator',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/generator)[\\/]/,
priority: -5,
},
babel_helper: {
name: 'vendors-helper',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/helper?.*)[\\/]/,
priority: -5,
},
babel_runtime_helpers: {
name: 'vendors-runtime-helpers',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/runtime\/helpers)[\\/]/,
priority: -5,
},
babel_runtime_types: {
name: 'vendors-runtime-types',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/types)[\\/]/,
priority: -5,
},
babel_runtime_traverse: {
name: 'vendors-runtime-traverse',
chunks: 'all',
test: /[\\/]node_modules[\\/](@babel\/traverse)[\\/]/,
priority: -5,
},
},
},
};

if (env === 'production') {
conf.output = { ...conf.output, publicPath: './' };
conf.optimization = {
...conf.optimization,
splitChunks: {
cacheGroups: {
reactvendor: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'react-vendor',
chunks: 'all',
},
babelstandalone: {
test: /[\\/]node_modules[\\/](@babel[\\/]standalone)[\\/]/,
name: 'babel-standalone-vendor',
chunks: 'all',
},
prismjs: {
test: /[\\/]node_modules[\\/](refractor)[\\/]/,
name: 'refractor-vendor',
chunks: 'all',
},
codemirror: {
test: /[\\/]node_modules[\\/](@codemirror)[\\/]/,
name: 'codemirror-vendor',
chunks: 'all',
},
uiw: {
test: /[\\/]node_modules[\\/](@uiw)[\\/]/,
name: 'uiw-vendor',
chunks: 'all',
},
parse5: {
test: /[\\/]node_modules[\\/](parse5)[\\/]/,
name: 'parse5-vendor',
chunks: 'all',
},
},
},
};
}
return conf;
};
14 changes: 6 additions & 8 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,17 @@
"react-test-renderer": "17.0.2"
},
"devDependencies": {
"@kkt/less-modules": "6.11.0",
"@kkt/raw-modules": "6.11.0",
"@kkt/scope-plugin-options": "6.11.0",
"compile-less-cli": "1.8.9",
"@kkt/less-modules": "7.0.5",
"@kkt/raw-modules": "7.0.5",
"@kkt/scope-plugin-options": "7.0.5",
"compile-less-cli": "1.8.11",
"cross-env": "7.0.3",
"husky": "7.0.4",
"jest": "27.3.1",
"jest-environment-jsdom": "27.3.1",
"kkt": "6.11.0",
"kkt": "7.0.5",
"lint-staged": "11.2.6",
"prettier": "2.4.1",
"source-map-explorer": "2.5.2",
"tsbb": "3.4.4"
"tsbb": "3.5.4"
},
"eslintConfig": {
"extends": [
Expand Down

0 comments on commit 12685e4

Please sign in to comment.