reactjs - 在 Firebase 上部署后 React 应用程序显示空白页面
问题描述
我的 react 应用程序在 localhost 上运行良好,但是当我将它部署到 firebase 托管时,它显示空白页。它显示了这一点:
我在互联网上查找和堆栈溢出,有很多类似的解决方案,我尝试了所有但对我没有任何作用,这就是我再次询问的原因。我的 firebase.json 文件看起来像这样
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
我的 package.json 文件看起来像这样
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"firebase": "^7.23.0",
"firebase-admin": "^9.2.0",
"react": "^16.13.1",
"react-currency-format": "^1.0.0",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我应该怎么做才能在 firebase 托管上完美地工作?任何帮助表示赞赏?
解决方案
推荐阅读
- mysql - Rails 5 API - 即使无法建立与数据库的连接,也加载静态页面
- c# - 如何在 Unity 中制作动画天空盒?
- c - Makefile:尽管所有文件都在那里
- html - 如何在同一行对齐标题和无序列表
- css - CSS:无法让滚动条出现在水平滚动 DIV 上
- c# - Azure 函数访问存储帐户
- python - PyQt5:QPolygonF 的中心线
- android - Exoplayer : 在设置 mediaitem/mediasource 之前启用 TimeBar 的scrubber
- javascript - 如果在 React 中出现条件,如何渲染组件
- r - 如何单独对几列求和并创建散点图