首页 > 解决方案 > 部署到 Firebase 的 Angular 5 应用程序不会加载组件

问题描述

firebase init我能够使用和将 Angular 5 应用程序部署到 Firebase firebase deploy

默认情况下,主页index.html来自public目录。

firebase.json从:

{
  "hosting": {
    "public": "public",

至:

{
  "hosting": {
    "public": "src",

这样我index.html就被显示出来了。

它已显示,但未加载其中的组件。我被一个空页面困住了,<app-root></app-root>里面的标签是空的。

如何在我这边配置 firebase 以便它在我的本地主机上工作?

标签: angularfirebaseangular5firebase-hosting

解决方案


您的项目文件夹,以指示 Angular CLI 在 dist 文件夹中为您的应用程序构建生产就绪的资产集:

ng build --prod
npm install -g firebase-tools
firebase login
firebase init

公共目录:输入dist,因为这是您的生产就绪 Angular 应用程序资产所在的位置。

配置为单页应用程序:大多数时候你会说yes (y)这个。覆盖 index.html:No.

源代码


推荐阅读