Joh*_*ika 5 ember.js ember-cli
我想为暂存环境创建一个Ember CLI应用程序的版本.对于分段,我想基本上做与生产(缩小,指纹识别,排除测试等)完全相同的事情,但是想要获取用于开发的环境变量.为了尝试这个,我将我的environment.js文件更改为暂存帐户:
if (environment === 'development' || environment === 'staging') {
ENV.someApiKey = 'test-api-key';
}
if (environment === 'production') {
ENV.someApiKey = 'production-api-key';
}
Run Code Online (Sandbox Code Playgroud)
当我运行时ember build --environment=staging,会设置正确的登台环境变量,但是所有其他将用于生产的构建过程都不会.有没有办法告诉Ember CLI构建生产但是为开发选择环境变量?
Ember 根据 /ember-cli/lib/broccoli/ember-app.js 中是否指定了 Production ONLY 设置一个标志:
var isProduction = this.env === 'production';
然后它使用特定于生产的设置。
因此,如果您想要进行暂存构建,请在运行 ember 构建之前使用一个过程来修改environment.js,然后在构建完成后将文件恢复到正常状态。将来我们可能应该使这个过程更加灵活。