ExtJS的(5)建立煎茶不同的环境配置 [英] ExtJS (5) Sencha build configurations for different environments

查看:198
本文介绍了ExtJS的(5)建立煎茶不同的环境配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ExtJS 5.0的应用程序,它指向的API。在开发,我想使用的http://本地主机生产当然其他服务器。

I have an ExtJS 5.0 app that points to an API. On development, I'd like to use http://localhost but on production of course some other server.

有没有办法煎茶应用程序构建过程中设置来自外部的应用程序的变量?或code访问某些ENV变量?

Is there a way to set an app's variable from the outside during sencha app build ? Or access some ENV variable in the code?

将是巨大的,如果有人可以帮助我。

Would be great if anybody could help me.

非常感谢你,

塞巴斯蒂安

推荐答案

我发现这样做的方式,但我不知道这是最好的方式。在你app.json,你会发现这样的内容:

I found a way of doing this but I am not sure it is the best way. In your app.json you will find a section like this:

/**
 * override objects for setting build environment specific 
 * settings.
 */
"production": {
    banana : 'no'
},
"testing": {
    banana : 'yes'
},
"development": {

},

显然,我已经添加了香蕉园自己。我们不允许部署在生产中的香蕉,所以我设置的值yes或no根据环境。

Obviously I have added the banana field myself. We are not allowed to deploy a banana in production so I set the value yes or no based on the environment.

然后,在建立我是否做'煎茶的应用程序构建测试或煎茶的应用程序建立生产,将建立对环境到Ext.manifest对象各自的香蕉价值。

Then at build whether I do 'sencha app build testing' or 'sencha app build production' it will build in the respective banana value for the environment into the Ext.manifest object.

因此​​,在应用我可以通过访问该值:

So in the application I can access the value through:

if (Ext.manifest.banana === "yes")

我presume可以使用同样的技术来定义其它水果领域,甚至可能是无果相关的数据。

I presume you can use the same technique to define fields for other fruit, or perhaps even non-fruit related data.

我从这个文件的想法:
当你启动应用程序,你会发现加载app.json的处理的内容Ext.manifest。
<一href=\"http://docs.sencha.com/cmd/5.x/microloader.html\">http://docs.sencha.com/cmd/5.x/microloader.html

就像我说的,我不知道这是否是做的最好的方式,但我怀疑它可能是。

Like I said I don't know if this is the best way to do it but I suspect it might be.

这篇关于ExtJS的(5)建立煎茶不同的环境配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆