Firebase 托管在部署 angular 6 应用程序后显示欢迎页面?

问题描述 投票:0回答:11

我想开发 angular 6 应用程序,但在部署 firebase 后只显示欢迎页面。

这是我部署的步骤。

  1. 已安装的 firebase-tools
  2. ng build --prod(在我的应用程序中)
  3. firebase 初始化
  4. 准备好继续了吗? (是/否)是
  5. (*) 托管:配置和部署 Firebase 托管站点
  6. 你想用什么作为你的公共目录? (公共)dist
  7. 配置为单页应用(将所有url重写为/index.html)? (是/否)是
  8. 文件 dist/index.html 已经存在。覆盖? (是/否)是
  9. Firebase 初始化完成!
  10. 在这一步中,我删除了dist文件夹并再次运行
    ng build --prod
  11. angular build app 在
    dist
    目录中的子文件夹中,因此我将包含 index.html 的子目录中的所有内容复制到
    dist/
    .
  12. firebase 部署
  13. firebase 开放托管:网站

但在完成所有这些之后,我仍然在链接中看到欢迎页面。

我做错了什么!?

angular firebase firebase-hosting
11个回答
18
投票

尝试: 8. 文件 dist/index.html 已经存在。覆盖? (是/否)否 并以隐身模式打开指向您的应用程序的链接。说真的,我坚持了几个小时,因为这个 firebase 索引在我的案例中被缓存了,所以这就是为什么我在部署后看不到我的应用程序的原因。


3
投票

问题是: firebase 正在寻找

index.html
文件,有时它不直接存在于
dist
目录中

解决方案:

public
中的
firebase.json
路径更新为
"public":"dist/ProjectName"
index.html
文件夹中的
dist
文件路径

例子

{
  "hosting": {
    "public": "dist/<YourProjectName>",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/dist/index.html"
      }
    ]
  }
}

2
投票

浏览器缓存也是我的问题。如上所述,尝试隐身或使用 proxysite.com(非常有用的网站)以避免浏览器缓存


1
投票

就我而言,我在项目目录中初始化 firebase (

src
)。只需检查您所在的目录。它应该在顶层。

构建并尝试部署后,由于网页已缓存,因此它将相同。所以要确保在

incognito
.

中使用

0
投票

检查终端上的路径。如果问题仍然存在,则删除 firebase 自动创建的文件夹并部署项目


0
投票

配置为单页应用(将所有url重写为/index.html)?不 ?使用 GitHub 设置自动构建和部署?否

  • 写了 public/404.html ?文件 public/index.html 已经存在。覆盖?否

此错误是由您网站文件夹的公用文件夹中的 index.html 生成的。


0
投票

在我的例子中,我必须在 firebase.json 中将

public
更改为
dist
,以便在我将 Firebase 函数添加到我的项目后它指向我的 dist 文件夹(而不是包含持有页面的公用文件夹):

"hosting": {
   "public": "dist",
   ...
}


0
投票

欢迎页面是在 public 文件夹中自动生成的 index.html 文件。我用我自己的 index.html 文件替换了那个文件,然后使用

firebase deploy --only hosting
命令来更新更改。


0
投票

首先你应该登录 firebase 登录 在那之后写命令 firesbe init

第一步 1)你想用什么作为你的公共目录? (公共)dist/projectname 2)文件dist/index.html已经存在。覆盖? (是/否)N

完成流程后 你应该运行(npm run build)命令并生成构建文件 之后你应该得到 firebase.json 并将构建文件夹放在公共目录中 { “托管”:{ “公共”:“构建”, “忽略”: [ “firebase.json”, "/.*", “/node_modules/” ], “重写”:[ { “来源”:“”, “目的地”:“/dist/index.html” } ] } }

最后一个并非最不重要的 firebase 部署。工作完美


-1
投票

这对我有用:

  • 删除 .firebase 文件夹
  • 删除.firebaserc
  • 删除 firebase.json

现在运行如下:

$ firebase init hosting
? File build/web/index.html already exists. Overwrite? No
$ firebase deploy --only hosting

-1
投票

firebase 初始化托管 ?文件 build/index.html 已经存在。覆盖?不 npm 运行构建 firebase 部署——仅托管

© www.soinside.com 2019 - 2024. All rights reserved.