react umi splitChunks分包后, 设置 chunks为all时无法加载出页面(一片空白),为async可以正常出现,但是无法分包
下面是config 配置文件代码
——-----------------------——————————————————————————————————
import { defineConfig } from 'umi';
import pxToViewport from 'postcss-px-to-viewport';
import routes from './routes';
import proxy from './proxy';
export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
hash: true,
history: {
type: 'hash',
},
routes: routes,
fastRefresh: {},
proxy,
mock: false,
// publicPath: '/zscms/poseidon-front-h5/',
publicPath: '/poseidon-front-h5/',
manifest: {
basePath: '/poseidon-front-h5/',
},
extraPostCSSPlugins: [
pxToViewport({
viewportWidth: 375,
unitPrecision: 3,
viewportUnit: 'vw',
selectorBlackList: [],
minPixelValue: 1,
mediaQuery: false,
// exclude: [/node_modules/],
}),
],
analyze:{
analyzerMode:'server',
analyzerPort:8888,
openAnalyzer:true,
generateStatsFile:false,
statsFilename:'stats.json',
logLevel:'info',
defaultSizes:'parsed',// stat // gzip
},
chainWebpack (config, { webpack }) {
try {
console.log('启动');
config.optimization.splitChunks({
chunks: 'async',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
name: 'vendors',
chunks: 'async',
test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|moment)[\\/]/,
priority: -10,
},
antdesigns: {
name: 'antdesigns',
chunks: 'async',
test: /[\\/]node_modules[\\/](@ant-design|antd)[\\/]/,
priority: -11,
}
},
});
}catch(err){
console.log(err+'失败');
}
}
});
function err(err: any) {
throw new Error('Function not implemented.');
}
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。
同问