首页 > 解决方案 > 如何在 Github Pages 上修改已部署的 create-react-app?

问题描述

我混合使用这两个教程( https://create-react-app.dev/docs/deploymenthttps://github.com/gitname/react-gh-pages在 GitHub Pages 上部署了一个 create-react-app )。它工作得很好。

但是这个网页应该会定期更新,我有一些内容要补充。

有没有办法修改已部署的应用程序?如何将我在本地目录中所做的更改推送到 gh-pages(生产模式)?添加后是否需要再次运行 npm build ?

目前我在 master 分支上有开发模式。我认为这是 gh-pages 上的构建模式,虽然我没有任何其他分支。

谢谢您的帮助。

我做了什么部署:

终端

$ npm install --save gh-pages

$ git init

$ git remote add origin https://github.com/REMOTE

$ npm run deploy

包.json

{
    "homepage": "https://USER-PAGE.github.io/",  
    "scripts": {
        "predeploy": "npm run build",            
        "deploy": "gh-pages -b master -d build",
    },
    "devDependencies": {
        "gh-pages": "^2.1.1"
    }
}

标签: github-pages

解决方案


要修改站点,只需进行更改,然后像通常对所需分支所做的那样 git add、commit 和 push。

然后再次运行命令:

npm run deploy

推荐阅读