【问题标题】:How to show application content and not firebase hosting documentation when deploying? [closed]部署时如何显示应用程序内容而不是 Firebase 托管文档? [关闭]
【发布时间】:2020-09-06 06:36:26
【问题描述】:

我使用文档设置了我的 firebase,但是当我运行“firebase deploy”时,它显示的是托管文档而不是我的应用程序。我见过的教程做同样的事情,它适用于他们。 我尝试编辑 firebase 公共目录附带的 index.html,它似乎只要它的简单文本就可以工作,但是当我复制我的 Angular app.component.html 或复制其他一些组件的 html 时,它变成空白。我不确定如果我需要编辑公共目录的 HTML,我会假设它会在我更改项目的 HTML 时自动更新。假设使用 firebase 托管在 firebase 上显示我的项目的 html 模板。

【问题讨论】:

    标签: html angular firebase firebase-hosting


    【解决方案1】:

    这就是我将 Angular 项目部署到 Firebase 的方式

    ng build --prod - 构建生产包

    npm install -g firebase-tools - 安装 firebase 工具(如果尚未安装)

    firebase login - 登录您的帐户(这将打开网页,您需要使用您的 google 帐户允许 firebase)

    重要

    firebase init - 在项目顶级路径中运行此命令。选择托管,然后按 Enter。将公共目录更改为 dist 并确保您的包的所有文件/文件夹都直接在 dist 文件夹中。 Y(Yes) 配置为单页应用,N(No) 覆盖 index.html

    firebase deploy - 部署项目

    注意:

    确保您在dist 文件夹中直接有index.html(您的角度文件),并检查您在firebase.json 中的公共目录是什么。应该是hosting > public > dist

    Angular cli 生成类似 dist/YOUR-PROJECT-NAME-FOLDER/index.html 的文件,确保它就像直接在 dist 中一样,例如 dist/index.html

    【讨论】:

    • 我完成了所有步骤到 firebase 部署,但它没有部署我的项目,它出于某种原因部署了 firebase 托管文档。
    • @Mohammad 答案已更新,看看是否能解决您的问题
    • 我将我的项目 index.html 复制粘贴到 dist index.html 中。我的 firebase.json 看起来像 { "hosting": { "public": "public", "ignore": [ "firebase.json", "/.*", "*/node_modules/ i>" ], "rewrites": [ { "source": "*", "destination": "/index.html" } ] } } 我的 dist 文件夹看起来像 dist/project 然后 index.html .不同的是命名约定有 dist/project 然后里面是 html 没有 dist 然后是项目文件夹然后是 index.html。他们将 dist/project 合二为一,然后是 index.html。
    • @Mohammad 做一件事,将firebase.json 中的public 更改为dist,您的包文件应该类似于dist/index.html 和dist/ALL-OTHER-FILES
    • 我更改了 public:"dist" 并通过 firebase 获取页面未找到错误。这是我得到的错误您可能为您的应用程序部署了错误的目录。检查您的 firebase.json 并确保 public 目录指向包含 index.html 文件的目录。并且不确定如何指向包含哪个 index.html 的正确目录?有多个
    猜你喜欢
    • 2021-05-09
    • 2019-10-10
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    相关资源
    最近更新 更多