ExtJS (5) Sencha build configurations for different environments

后端 未结 1 656
醉话见心
醉话见心 2021-02-20 11:03

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

1条回答
  •  [愿得一人]
    2021-02-20 11:17

    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": {
    
    },
    

    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.

    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")
    

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

    I got the idea from this document: "When you launch your application, you will find the processed content of app.json loaded as “Ext.manifest”." 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.

    0 讨论(0)
提交回复
热议问题