What happens?
使用 UMI_ENV 环境变量定义多环境配置 添加 webpack5:{} 选项,构建时报错
Mini Showcase Repository(REQUIRED)
复现仓库地址:
https://github.com/zhanghaoxu/umijs-3.5.43-multienv-bug
How To Reproduce
主配置
import { defineConfig } from 'umi';
const isProd = process.env.UMI_ENV === 'prod';
console.log(isProd, process.env.UMI_ENV);
export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
routes: [{ path: '/', component: '@/pages/index' }],
fastRefresh: {},
});
prod 环境配置
import { defineConfig } from 'umi';
export default defineConfig({
webpack5: {},
});
执行脚本 npm run start:prod 引入多环境配置 报错:
Context
- Umi Version: 3.5.43
- Node Version:20.19.4
- Platform: macos 26.0.1