简体   繁体   English

如何以root用户身份使用create-react-app更新自定义GitHub Pages

[英]how to update a custom GitHub Pages with create-react-app as root

Hello I have read many docs online on connecting gh-pages with create-react-app. 您好,我在线阅读了许多有关将gh页与create-react-app连接的文档。 But most guides either assume that one does not already have a github pages set up, and that the react app is to be hosted as a directory (ie. username.github.io/react-app) instead of the homepage/root (username.github.io). 但是大多数指南都假设尚未设置github页面,并且react应用将作为目录(即username.github.io/react-app)而不是homepage / root(用户名)托管。 .github.io)。 I am hoping someone can help me out: 我希望有人可以帮助我:

  1. I have an existing repo for a github pages custom domain. 我有一个用于github页面自定义域的现有存储库。 It is currently hosting an older site I built with gulp and static html/css/js, and a CNAME file for custom url. 目前,它托管着一个我用gulp和静态html / css / js构建的旧站点,以及一个用于自定义URL的CNAME文件。

  2. I built a new website redesign with create-react-app in a separate repo (It uses react-router for multiple pages). 我在单独的存储库中使用create-react-app构建了一个新的网站重新设计(它对多个页面使用react-router)。

  3. I want to overwrite the contents of my old github pages site with my new create-react-app website as the root homepage. 我想用新的create-react-app网站作为根主页覆盖旧github页面网站的内容。

Is this possible? 这可能吗? If so, what is the best way to achieve this? 如果是这样,实现此目标的最佳方法是什么? Thanks 谢谢

  1. In the existing Github Pages app, remove the CNAME and/or delete master branch. 在现有的Github Pages应用中,删除CNAME和/或删除master分支。 Deleting master branch will remove the site, while deleting CNAME will clear up the custom domain back to default [username].github.io. 删除master分支将删除该站点,而删除CNAME会将自定义域清除回默认的[username] .github.io。

  2. In create-react-app, add CNAME to /public folder. 在create-react-app中,将CNAME添加到/ public文件夹。

  3. In create-react-app, add line "homepage":"./" to package.json . 在create-react-app中,将"homepage":"./" to package.json添加行"homepage":"./" to package.json
  4. In create-react-app, run npm run build then run gh-pages -d build build process, then run npm run deploy 在create-react-app中,运行npm run build然后运行gh-pages -d build构建过程,然后运行npm run deploy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用github页面的create-react-app的自定义域 - Custom domain using create-react-app for github pages 使用create-react-app + github页面的自定义域名 - Custom domain name with create-react-app + github pages 在Github Pages上更改为自定义域会导致带有react-router的create-react-app停止工作 - Changing to custom domain on Github Pages causes create-react-app with react-router to stop working Github页面上的Create-React-App返回一个空白页面 - Create-React-App on Github-pages returns a blank page 无法在 Github 页面上部署新的 create-react-app - Cannot deploy fresh create-react-app on Github Pages 无法将 create-react-app 部署到 github-pages - cannot deploy create-react-app to github-pages 如何将 create-react-app 部署到 github 页面? 收到“致命:无法从远程存储库读取”。 - How to deploy create-react-app to github pages? getting "fatal: Could not read from remote repository." 将React Webpack应用程序(不是使用create-react-app创建)部署到Github页面 - Deploying a React Webpack app (not created with create-react-app) to Github pages 无法使用Create-React-App在github页面中发布我的React App-控制台出现错误 - Cannot publish my react App in github Pages with Create-React-App - got an Error in console 使用 create-react-app 将 React 应用程序部署到 github 页面不起作用 - Deploy React app using create-react-app to github pages isn't working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM