Angular2 托管在 Firebase 上
Angular2 hosting on Firebase
我按照所有必要的步骤在 Firebase 上托管了我的 Angular2 网站
firebase login
firebase init (single page app replace index.html file YES)(folder public)
firebase deploy
但是我的网站只有欢迎模板(欢迎
Firebase 托管设置完成等...)
我尝试 delete/replace/customise index.html 文件夹中的 public 文件,但欢迎模板仍然存在...
如何用我自己的网站替换此模板?
我的firebase.json内容:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
您在 firebase.json
中的 hosting
指向错误的目录。
如果你做一个build,目标是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
(或 V6 的 angular.json
)中检查构建目标
"outDir": "location/of/dist/folder"
(或 V6 的 "outputPath": "location/of/dist/folder"
)
此外,如果您在 firebase init
之前已经构建了项目。如果必须覆盖 index.html
,应该会提示您。
您可以重新运行 firebase init
而不是编辑 firebase.json
我按照所有必要的步骤在 Firebase 上托管了我的 Angular2 网站
firebase login
firebase init (single page app replace index.html file YES)(folder public)
firebase deploy
但是我的网站只有欢迎模板(欢迎 Firebase 托管设置完成等...)
我尝试 delete/replace/customise index.html 文件夹中的 public 文件,但欢迎模板仍然存在...
如何用我自己的网站替换此模板?
我的firebase.json内容:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
您在 firebase.json
中的 hosting
指向错误的目录。
如果你做一个build,目标是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
(或 V6 的 angular.json
)中检查构建目标
"outDir": "location/of/dist/folder"
(或 V6 的 "outputPath": "location/of/dist/folder"
)
此外,如果您在 firebase init
之前已经构建了项目。如果必须覆盖 index.html
,应该会提示您。
您可以重新运行 firebase init
firebase.json