在Firebase上部署后,React应用程序显示空白页面

时间:2020-10-17 07:18:42

标签: reactjs firebase deployment firebase-hosting

我的react应用在localhost上运行正常,但是当我将其部署在Firebase托管上时,它显示空白页面。它显示此: enter image description here

我在Internet上查找并且出现堆栈溢出,有很多类似的解决方案,我都尝试了所有解决方案,但对我来说却无济于事,这就是为什么我再次询问。我的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托管上完美地工作?感谢您的帮助吗?

0 个答案:

没有答案