如果你将单页面应用程序(SPA)部署到 Firebase,但没有进行渲染,可能是由于以下原因:
index.html
文件。你可以在 firebase.json
文件中添加以下配置:
{ "hosting": { "public": "build", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }npm run build
或 yarn build
)来生成生产环境的代码。firebase deploy
命令来部署你的应用程序。firebase.json
文件中添加缓存控制规则:
{ "hosting": { "public": "build", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ], "headers": [ { "source": "**/*.@(js|css)", "headers": [ { "key": "Cache-Control", "value": "public, max-age=31536000" } ] } ] } } npm install
或 yarn install
来安装依赖项。领取专属 10元无门槛券
手把手带您无忧上云