Why is ant design pro not using config.dev.ts despite correctly passing in UMI_ENV=dev

198 Views Asked by At

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.

1

There are 1 best solutions below

0
Nicky On

Umi.js config profile priority:

The higher up, the more specific and higher the priority, and high-quality ones can be moved down.

config.ts

config.${UMI_ENV}.ts

config.${dev | prod}.ts

config.${dev | prod}.${UMI_ENV}.ts

config.local.ts

I try below way to solve this problem:

{
  "script": {
    "build": "cross-env UMI_ENV=prod max build",
    "build:test": "cross-env UMI_ENV=test max build",
  }
}

Create files: /config/config.prod.prod.ts and /config/config.prod.test.ts .

More discussion: https://github.com/umijs/umi/discussions/8341