Skip to content
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

Merged
merged 3 commits into from
May 22, 2018

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented May 22, 2018

Notes:

  • 如果有配 UMI_ENV,比如 UMI_ENV=cloud,则会用 config/config.cloud.js 合并 config/config.js
  • dev 模式下时会额外加载 .local.js,并合并到配置里
  • 此方式同样支持 .umirc.js,比如 .umirc.local.js
  • *.local.js 的配置文件通常需要添加到 .gitignore,不要提交

@coveralls
Copy link

coveralls commented May 22, 2018

Pull Request Test Coverage Report for Build 458

  • 8 of 29 (27.59%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 21.557%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/umi-build-dev/src/registerBabel.js 0 8 0.0%
packages/umi-build-dev/src/UserConfig.js 8 21 38.1%
Files with Coverage Reduction New Missed Lines %
packages/umi-build-dev/src/registerBabel.js 1 0.0%
Totals Coverage Status
Change from base Build 452: 0.1%
Covered Lines: 483
Relevant Lines: 2471

💛 - Coveralls

export function getEnv() {
let env = process.env.UMI_ENV;
if (process.env.NODE_ENV === 'development') {
env = 'local';
Copy link
Contributor

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'),
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,我更新下。

@sorrycc
Copy link
Member Author

sorrycc commented May 22, 2018

Updated @yutingzhao1991

flatten(
CONFIG_FILES.map(file => [
file,
env ? [file.replace(/\.js$/, `.${env}.js`)] : [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是少了一个 config.local.js

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,已加。

@sorrycc sorrycc merged commit d29bab9 into master May 22, 2018
@sorrycc sorrycc deleted the feat/config-via-env branch May 22, 2018 02:39
sorrycc pushed a commit that referenced this pull request Jun 23, 2022
* chore(scripts): ✏️ support write commit msg between comments

* chore: ✏️ typo

* chore: ✏️ another missing typo

Co-authored-by: pshu <pishu.spf@antfin.com>
xierenyuan pushed a commit to xierenyuan/umi that referenced this pull request Jun 23, 2022
* chore(scripts): ✏️ support write commit msg between comments

* chore: ✏️ typo

* chore: ✏️ another missing typo

Co-authored-by: pshu <pishu.spf@antfin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants