Currently, I have a folder structure that looks like this
.
└── config/
├── config.dev.ts
├── config.local.ts
├── config.ts
└── defaultSettings.ts
My Package.json commands look like this:
"ant:start:localapi": "cross-env REACT_APP_ENV=local UMI_ENV=local HTTPS=true MOCK=none umi dev"
"ant:start:devapi": "cross-env REACT_APP_ENV=dev UMI_ENV=dev HTTPS=true MOCK=none umi dev"
Here is my dev configuration file:
// https://umijs.org/config/
import { defineConfig } from 'umi';
export default defineConfig({
plugins: [
// https://github.com/zthxxx/react-dev-inspector
'react-dev-inspector/plugins/umi/react-inspector',
],
// https://github.com/zthxxx/react-dev-inspector#inspector-loader-props
inspectorConfig: {
exclude: [],
babelPlugins: [],
babelOptions: {},
},
define: {
'process.env.UMI_ENV': process.env.UMI_ENV,
...
},
});
When I run ant:start:devapi, Umijs ends up using the config.local.ts file despite correctly passing in the UMI_ENV env variable.
I understand that there is prioritization that happens where local is to be used if UMI_ENV is not present, however, I have confirmed that UMI_ENV is passed correctly as dev.
I don't understand what I'm doing wrong.
Umi.js config profile priority:
The higher up, the more specific and higher the priority, and high-quality ones can be moved down.
I try below way to solve this problem:
Create files:
/config/config.prod.prod.tsand/config/config.prod.test.ts.More discussion: https://github.com/umijs/umi/discussions/8341