Kay*_*ues 35 firebase firebase-hosting firebase-tools
我刚刚使用Firebase CLI来初始化静态托管项目.启用"配置为单页应用程序"选项时会发生什么?我正在寻找一个关于哪些文件被修改的描述,以及它对Firebase后端的影响.
Fra*_*len 57
该选项只是在firebase.json文件中设置一个标志,以将所有URL重定向到/index.html.
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅Firebase Hosting的文档.
ast*_*mme 20
完整示例:
{
"hosting": {
"public": ".",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
Jer*_*yal 13
如果您将其设置为 yes,那么所有无效的 URLwww.example.com/some-invalid-url都将被重定向到index.html您的站点,这是一件好事。您也可以将其设置为您的自定义404.html.
firebase.json
{
"hosting": {
"public": "pubic",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"cleanUrls": true
}
}
Run Code Online (Sandbox Code Playgroud)
奖励:设置cleanUrls以true删除.html从您的部署网站网址其他所有URL扩展,而不.html会重定向到index.html。
请注意:如果您想要服务器端渲染 (SSR),请键入“否”rewrites并按如下方式进行设置:
"rewrites": [
{
"function": "angularUniversalFunction",
"source": "**"
}
]
Run Code Online (Sandbox Code Playgroud)
毕竟,无论您选择什么,您都可以在firebase.json文件中更改它。
| 归档时间: |
|
| 查看次数: |
15824 次 |
| 最近记录: |