在更改路线或检测到新版本时,将更新版本部署在Firebase主机上,部署>

问题描述 投票:1回答:1

问题:

我们是否可以通过更改路线(或重点关注标签)并重新加载页面来检查部署在firebase托管上的新版本,以便用户可以查看新功能?当前用户必须刷新站点才能查看构建中部署的新功能。

以下是我的项目中当前安装的依赖项:

"dependencies": { "@material-ui/core": "^4.5.0", "antd": "^3.23.6", "axios": "^0.19.0", "env-cmd": "^10.0.1", "firebase": "^7.4.0", "highcharts": "^7.2.0", "highcharts-react-official": "^2.2.2", "history": "^4.10.1", "loaders.css": "^0.1.2", "local-storage": "^2.0.0", "moment": "^2.24.0", "node-sass": "^4.12.0", "notistack": "^0.9.2", "qs": "^6.9.0", "query-string": "^6.9.0", "react": "^16.12.0", "react-dom": "^16.12.0", "react-ga": "^2.7.0", "react-google-login": "^5.0.7", "react-icons": "^3.7.0", "react-loaders": "^3.0.1", "react-mentions": "^3.3.1", "react-redux": "^7.1.1", "react-router-dom": "^5.1.2", "react-scripts": "3.1.2", "redux": "^4.0.4", "redux-thunk": "^2.3.0" }

那是我的firebase.json配置当前的样子:

{ "hosting": { "target": "build", "public": "build", "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "rewrites": [ { "source": "**", "destination": "/index.html" } ], "headers": [ { "source": "**/*.@(jpg|jpeg|gif|png|css|js|jsx|scss|ttc|woff)", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] \\ so user doesn't have to force refresh build } ] } }

可能的解决方案:

    存储内部版本号,并在更新时添加侦听器,重新加载页面。
  • 检查内部版本号/时间戳,并以某种方式将其与最新的Firebase主机相匹配。
  • 有人可以指导我正确的方向吗?我也在Github上创建了一个问题。请让我知道是否需要我提供更多详细信息。

问题:我们是否可以通过更改路线(或集中精力于选项卡)并重新加载页面来检查部署在Firebase托管上的新版本,以便用户可以查看新功能?当前用户...

reactjs firebase firebase-hosting
1个回答
0
投票
我能够为我的问题找到解决方案。我最终在Cloud Firestore数据库中添加了一个版本集合,该集合通过一个脚本从CI / CD管道中进行更新,该脚本解析package.json文件的当前版本并将其存储在Cloud Firestore中。在React的主要App组件中,我向版本集合添加了一个侦听器,该监听器可以比较版本并相应地重新加载页面。
© www.soinside.com 2019 - 2024. All rights reserved.