繁体   English   中英

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

[英]Firebase hosting showing welcome page after deploying angular 6 app?

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

以下是我已采取的部署步骤。

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

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

我究竟做错了什么??

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

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

就我而言,我在项目目录( src )中初始化 firebase 。 只需检查您所在的目录。它应该在顶层。

在您构建它并尝试部署它之后,它将是相同的,因为 web 页面已被缓存。 所以要确保使用incognito

问题是: firebase 正在寻找index.html文件,有时它不直接存在于dist目录中

解决方法:firebase.json中的public路径更新为"public":"dist/ProjectName"或者dist文件夹下index.html文件的路径

例子

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

这对我有用:

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

现在运行如下:

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

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

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

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

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

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

在我的例子中,我必须在 firebase.json 中将public更改为dist ,以便在我将 Firebase Functions 添加到我的项目后它指向我的 dist 文件夹(而不是包含保留页面的 public 文件夹):

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

欢迎页面是在public文件夹中自动生成的 index.html 文件。 我用自己的 index.html 文件替换了该文件,然后使用firebase deploy --only hosting命令来更新更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM