【问题标题】:ExtJS 6 app.js does not updates after new production releaseExtJS 6 app.js 在新的产品发布后不会更新
【发布时间】:2017-06-14 14:26:27
【问题描述】:

我们正在使用 Extjs 6 并且我们正在使用 sencha cmd 来构建我们的应用程序。

我们正面临一个问题。每次我们发布应用程序的生产版本(如 6.3 到 6.4)时,捆绑的 app.js 不会更新,浏览器会从 (from disk cache) 获取该文件。因此,每次我们都必须告诉我们的用户,请在您获得新版本后清除浏览器的缓存。 That's annoying.

这是我的 app.json 文件。

"output": {
        "base": "${workspace.build.dir}/${build.environment}/${app.name}",
        "page": "index.html",
        "manifest": "${build.id}.json",
        "js": "${build.id}/.js",
        "appCache": {
            "enable": false,
            "update": "full"
        },
        "resources": {
            "path": "${build.id}/resources",
            "shared": "resources"
        }
    },
"production": {
        "output": {
            "appCache": {
                "enable": false,
                "path": "cache.appcache"
            }
        },
......
"cache": {
            "enable": false 
        }
...

【问题讨论】:

标签: extjs extjs6.2


【解决方案1】:

这里有两个选项可以解决您的问题:

自定义 app.js 文件名

        {
            "production": {
                "output": {
                    "js": "${build.id}/app_${build.timestamp}.js"
                },
                "cache": {
                    "enable": true
                },
                "js": [
                    {
                        "path": "${build.id}/app.js",
                        "bundle": true,
                        "includeInBundle": false
                    }
                ],
          "output": {
            "base": "${workspace.build.dir}/${build.environment}/${app.name}",
            "page": "index.html",
            "manifest": "${build.id}.json",
            "js": "${build.id}/app_${app.version}.js",
            "appCache": {
                "enable": false,
                "update": "full"
            },
            "resources": {
                "path": "${build.id}/resources",
                "shared": "resources"
            }

        }
    }

这样,您每次构建应用时都会获得一个新的文件名 app.js

添加静态缓存参数

  {
        "production": {
            "loader": {
                "cache": "${build.timestamp}"
            },
            "cache": {
                "enable": true
            }
        }
    }

通过这个解决方案,ExtJs 将在app.js 请求中附加一个?_dc=12345678 参数。在您下一次构建之前,此参数保持不变。

【讨论】:

  • 我都试过了。首先:它试图在应用程序中找到确切的文件名,因此给出错误,第二个选项:它在请求中附加“_dc”,但仍然浏览器缓存该文件,因此无法正常工作全部。
  • 您使用哪个版本的 Sencha Cmd?我已经用版本 6.2.2.36 (ExtJs 6.2.1) 进行了尝试。经典或现代工具包?
  • @RonakPatel 这是我完全简化的app.jsongist.github.com/astepin/fb1e95f753e9057570cf86e79179a48f
  • 需要对 app.json 进行少许更改,但您的回答帮助我 +1
【解决方案2】:

我找到了解决办法:

"js": [
        {
            "path": "app.js",
            "bundle": true,
            "includeInBundle": false
        }
    ],
.....
"output": {
        "base": "${workspace.build.dir}/${build.environment}/${app.name}",
        "page": "index.html",
        "manifest": "${build.id}.json",
        "js": "${build.id}/app_${app.version}.js",
        "appCache": {
            "enable": false,
            "update": "full"
        },
        "resources": {
            "path": "${build.id}/resources",
            "shared": "resources"
        }
    },
....

这不会在生产版本中包含app.js 文件,并创建新的app.js 文件,并在其最后附加版本,例如:app_6.4.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多