运行 本地 Firebase 托管时无法更新更改 index.html

Can't update change index.html when running Firebase Hosting locally

我是网络开发的新手。我遵循了 Firebase 团队在 YouTube 上上传的本教程。 Deploy Python on Firebase Hosting with Cloud Run - Firecasts

将我的项目部署到云 运行 后,我能够 运行 在 Firebase 托管本地服务器 https://localhost:5000 上进行它。我想更改 index.html 中的代码,但即使在编辑器 (VScode) 中更改代码并刷新浏览器后,本地服务器也不会反映更改。现在,我必须 运行 以下内容来更新本地服务器中的更改,但这确实很耗时。

$gcloud builds submit --tag gcr.io/ projectName / serviceId

$gcloud run deploy serviceId --region us-central1 --platform managed --image gcr.io/ projectName / serviceId

$node_modules/.bin/firebase serve

有什么方法可以让我在 Firebase 托管本地服务器中看到 index.html 的变化,而无需 运行 上面的代码?

项目目录

project
   ---server
         ---Dockerfile
         ---src
             ---app.py
             ---templates
                    ---index.html
   ---static
         ---styles.css
         ---icons8-pause.png
   ---firebase.json
   ---.firebaserc
   ---package.json
   ---node_modules
     

index.html

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask + Firebase + CLoud Run = FIRE</title>
    <link rel="stylesheet" href="/styles.css">
  </head>
  <body class="full-screen flex-center">
    <h1 class="text-xl">FLASK + Firebase = Awesome + Cool + Nice</h1>
    <h2>Hello World</h2>
    <a href="/my-link/">Click me</a>
    <img src="/icons8-pause.png" alt="">
    <h3> {{ context.server_time }}</h3>
  </body>
</html>

firebase.json

{
  "hosting": {
    "public": "static",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],

    "rewrites": [{
      "source": "**",
      "run": {
        "serviceId": "serviceId"
      }
    }]
  }
}

当您将 Firebase 托管与云一起使用时 运行,不幸的是,有必要使用这些命令,因为您需要将应用程序容器化并将其上传到 Container Registry,以便进行部署。例如,即使在这个简单的 Hello World example 中,它也需要有命令 运行.

总而言之,考虑到您的应用程序的结构和格式 - 使用云部署 运行 - 您需要执行命令,因此应用程序已容器化并正确上传,因此部署发生正确。您也可以通过官方文档 here 获取所有详细信息。