From 755ce9113d2addb3e04c8b0c3f5fe2597c5a6105 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Tue, 4 Jan 2022 13:23:23 +0800 Subject: [PATCH] website: Fix startup service stuck. Startup service stuck https://github.com/kktjs/kkt/issues/330 Upgrade react-scripts to v5, Support Webpack 5.x https://github.com/kktjs/kkt/issues/198 --- .kktrc.ts | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/.kktrc.ts b/.kktrc.ts index c174baeb0..658d5e26c 100644 --- a/.kktrc.ts +++ b/.kktrc.ts @@ -23,25 +23,29 @@ export default (conf: Configuration, env: 'development' | 'production', options: VERSION: JSON.stringify(pkg.version), }), ); - - conf.optimization = { - ...conf.optimization, - splitChunks: { - cacheGroups: { - reactvendor: { - test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, - name: 'react-vendor', - chunks: 'all', + if (env === 'production') { + conf.optimization = { + ...conf.optimization, + splitChunks: { + cacheGroups: { + reactvendor: { + test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, + name: 'react-vendor', + chunks: 'all', + }, + refractor: { + test: /[\\/]node_modules[\\/](refractor)[\\/]/, + name: 'refractor-vendor', + chunks: 'all', + }, + codemirror: { + test: /[\\/]node_modules[\\/](@codemirror)[\\/]/, + name: 'codemirror-vendor', + chunks: 'all', + }, }, - // prismjs: { - // test: /[\\/]node_modules[\\/](codemirror)[\\/]/, - // name: 'codemirror-vendor', - // chunks: 'async', - // }, }, - }, - }; - if (env === 'production') { + }; conf.output = { ...conf.output, publicPath: './' }; } return conf;