【问题标题】:How to update version of a Flutter Web deployed in Firebase Hosting如何更新在 Firebase 托管中部署的 Flutter Web 版本
【发布时间】:2021-09-27 07:42:38
【问题描述】:

在旧版本的 Flutter 中,web/index.html 文件是使用内部调用 main.dart.js 的脚本构建的,但该脚本在较新版本中被删除,我曾经添加一个“版本”属性来指定版本,如何更新部署在 Firebase Hosting 上的 Flutter Web 版本?现在还有其他办法吗?

/// Original
<script src="main.dart.js" type="application/javascript"></script>

/// Modified
<script src="main.dart.js?version=10" type="application/javascript"></script>

【问题讨论】:

    标签: versioning flutter-web firebase-hosting


    【解决方案1】:

    尝试运行

    • flutter cleanflutter pub get

    • flutter build web 然后firebase deploy

    【讨论】:

    • 我知道了,但之前运行了“flutter clean”命令。
    【解决方案2】:

    我最终在 body 标记中手动添加了这个脚本,并在 firebase.json 文件中禁用了缓存。

    index.html

    <script src="main.dart.js?version=10" type="application/javascript"></script>
    

    firebase.json

    {
      "hosting": {
        "public": "build/web",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
    
        "headers": [
    
          {
            "source": "**",
            "headers": [
              {
                "key": "Cache-Control",
                "value": "no-cache"
              }
            ]
          }
    
        ]
      }
    
    
    }
    

    【讨论】:

      【解决方案3】:
      1. 调整您的项目并保存更改;
      2. 更改 pubspec.yaml 上的版本(例如从 1.0.0+1 到 1.0.1+1);
      3. 运行 flutter build web
      4. 运行 firebase deploy

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2016-12-27
      • 2020-07-03
      • 2021-03-28
      • 2021-09-28
      • 1970-01-01
      • 2017-01-22
      • 2021-09-25
      • 2019-10-05
      • 2022-01-13
      相关资源
      最近更新 更多