5

ExtJs7 生产和测试环境选择不同的配置

 2 years ago
source link: https://www.zhyea.com/2021/10/17/extjs7-seperate-prod-and-dev-config.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ExtJs7 生产和测试环境选择不同的配置

2021年10月17日 作者:白42

最近开始使用ExtJs7开发点儿小东西,其中有些配置在生产环境和测试环境是不一样的。本来想将就下,在生产和测试的时候分别改动下,但是改了几次后实在受不了了,想找个地儿统一管理下。

查了资料,在sencha论坛找到了这个帖子:Different API URL for development and Production。题主有和我相同的疑问,也得到了解答。但是美中不足的是,他们的方案只适用于extjs6.x版本。好在有方向了——可以从 app.json 文件着手,然后利用Ext.mainifest取值。

仔细看了一遍 app.json 文件,发现在这里可以发挥一下:

     * Settings specific to production builds.
    "production": {
        "output": {
            "appCache": {
                "enable": false,
                "path": "cache.appcache"
        "loader": {
            "cache": "${build.timestamp}"
        "cache": {
            "enable": true
        "compressor": {
            "type": "yui"
     * Settings specific to testing builds.
    "testing": {
     * Settings specific to development builds.
    "development": {
        "watch": {
            "delay": 250

这里的注释提示可以在相应的区域分别作 生产/测试/开发 环境的配置。

我在development区域添加了host配置:

    "development": {
        "watch": {
            "delay": 250
        "host": "http://baidu.com"

然后在Application.js中尝试读取host配置:

    onBeforeLaunch: function () {
        alert(Ext.manifest['host'])
        this.callParent();

在浏览器中刷新页面,看到了预期中的输出。Over!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK