-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(umi-build-dev): support config via env, e.g. config.{env}.js #515
Conversation
Pull Request Test Coverage Report for Build 458
💛 - Coveralls |
export function getEnv() { | ||
let env = process.env.UMI_ENV; | ||
if (process.env.NODE_ENV === 'development') { | ||
env = 'local'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样好像不对,umi dev 的时候需要用 config.local.js
assign 到配置,但是依然要保留用户传入的 UMI_ENV。比如 UMI_ENV=cloud umi dev
的情况下配置应该是:
{
...require('config.js'),
...require('config.cloud.js'),
...require('config.local.js'),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,我更新下。
Updated @yutingzhao1991 |
flatten( | ||
CONFIG_FILES.map(file => [ | ||
file, | ||
env ? [file.replace(/\.js$/, `.${env}.js`)] : [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是少了一个 config.local.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,已加。
* chore(scripts): ✏️ support write commit msg between comments * chore: ✏️ typo * chore: ✏️ another missing typo Co-authored-by: pshu <pishu.spf@antfin.com>
* chore(scripts): ✏️ support write commit msg between comments * chore: ✏️ typo * chore: ✏️ another missing typo Co-authored-by: pshu <pishu.spf@antfin.com>
Notes:
UMI_ENV
,比如 UMI_ENV=cloud,则会用config/config.cloud.js
合并config/config.js
.local.js
,并合并到配置里.umirc.js
,比如.umirc.local.js
*.local.js
的配置文件通常需要添加到 .gitignore,不要提交