javascript 部署一个使用index.html作为入口点的react应用

wfsdck30  于 2023-05-27  发布在  Java
关注(0)|答案(1)|浏览(162)

我在package.json中有以下代码-通常足以将react应用程序部署到github页面。这个应用程序略有不同,因为我在公共文件夹中使用index.html文件-有人知道将其部署到github页面的解决方案吗?
https://github.com/simharuk2021/reduxcart/tree/main/public
我已经尝试过使用URL,但没有什么区别,我只是在部署后显示了标准的react应用程序自述页面。

"name": "reduxcart",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "bootstrap": "^5.2.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.5",
    "react-scripts": "5.0.1",
    "reactstrap": "^9.1.10",
    "redux": "^4.2.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gh-pages": "^5.0.0"
  },
  "homepage": "https://simharuk2021.github.io/reduxcart/public/"
}```

  [1]: https://i.stack.imgur.com/BNSsY.png
55ooxyrt

55ooxyrt1#

您使用的是main分支进行部署,github页面要求您使用gh-pages分支,它应该是在您使用命令后自动创建的:npm run deploy。下面是引用:https://blog.logrocket.com/deploying-react-apps-github-pages/

相关问题