ExtJS 6 app.js does not updates after new production release

青春壹個敷衍的年華 提交于 2019-12-11 07:37:30

问题


We are using Extjs 6 and we are using sencha cmd to build our application.

We are facing one issue. Every time we release production version of our application like 6.3 to 6.4, bundled app.js does not get updated and browser take that file from (from disk cache). So every time we have to tell our users that please clear your browser's cache after you got new release. That's annoying.

This is my app.json file.

"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 
        }
...

回答1:


Here are two options to solve your issue:

Customize app.js filename

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

        }
    }

With this, you get every time you build your app an new file name for app.js.

Add static cache parameter

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

With this solution ExtJs will append a ?_dc=12345678 parameter to the app.js request. This parameter stays the same until your next build.




回答2:


I have found solution:

"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"
        }
    },
....

This will not include app.js file in production build and create new app.js file with version appended at last to it like: app_6.4.js.



来源:https://stackoverflow.com/questions/44522332/extjs-6-app-js-does-not-updates-after-new-production-release

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!