简体   繁体   English

Ember CLI:构建用于分段

[英]Ember CLI: Build for staging

I'd like to create a build of an Ember CLI app for a staging environment. 我想为暂存环境创建一个Ember CLI应用程序的版本。 For staging, I'd like to essentially do exactly the same thing as production (minification, fingerprinting, exclude tests, etc), but want to pick up the environment variables for development. 对于分段,我想基本上做与生产(缩小,指纹识别,排除测试等)完全相同的事情,但是想要获取用于开发的环境变量。 To attempt this, I changed my environment.js file to account for staging: 为了尝试这个,我改变了我的environment.js文件以考虑登台:

if (environment === 'development' || environment === 'staging') {
  ENV.someApiKey = 'test-api-key';
}

if (environment === 'production') {
  ENV.someApiKey = 'production-api-key';
}

When I run ember build --environment=staging , the proper staging environment variables are set, but all of the other build processes that would run for production doesn't. 当我运行ember build --environment=staging ,会设置正确的登台环境变量,但是为生产运行的所有其他构建过程都不会。 Is there a way to tell Ember CLI to build for production but pick up environment variables for development? 有没有办法告诉Ember CLI构建生产但是为开发选择环境变量?

Ember sets a flag depending on whether production ONLY is specified in /ember-cli/lib/broccoli/ember-app.js: Ember根据是否在/ember-cli/lib/broccoli/ember-app.js中指定了仅生产来设置标记:

var isProduction = this.env === 'production';

and then it uses the settings specific to production. 然后它使用特定于生产的设置。

So if you want to have a staging build use a process to modify the environment.js before your run ember build then when the build is finished revert the file back to normal. 因此,如果您想要一个临时构建,请在运行ember构建之前使用一个进程来修改environment.js,然后在构建完成时将文件恢复为正常状态。 We should probably make this process more flexible in the future. 我们应该在未来使这个过程更加灵活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM