angular - Firebase 上的 Angular2 托管
问题描述
我按照所有必要的步骤在 Firebase 上托管了我的 Angular2 网站
firebase login
firebase init (single page app replace index.html file YES)(folder public)
firebase deploy
但我的网站仅包含欢迎模板(欢迎 Firebase 托管设置完成等...)
我试图删除/替换/自定义公用文件夹中的 index.html 文件,但欢迎模板仍然存在...
如何用我自己的网站替换此模板?
我的 firebase.json 的内容:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
解决方案
您hosting
的 infirebase.json
指向错误的目录。如果您进行构建,并且目标是location/of/dist/folder
目录,则需要更改firebase.json
为
{
"hosting": {
"public": "location/of/dist/folder",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**" ],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
.angular-cli.json
您可以在(或angular.json
V6)
"outDir": "location/of/dist/folder"
(或"outputPath": "location/of/dist/folder"
V6)中检查构建目标
此外,如果您在firebase init
. 如果index.html
必须被覆盖,应该会提示您。
firebase.json
您可以重新运行,而不是编辑firebase init