[英]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:
我希望有人可以帮助我:
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文件。
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)。
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
谢谢
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。
In create-react-app, add CNAME to /public folder. 在create-react-app中,将CNAME添加到/ public文件夹。
"homepage":"./" to package.json
. "homepage":"./" to package.json
添加行"homepage":"./" to package.json
。 npm run build
then run gh-pages -d build
build process, then run npm run deploy
npm run build
然后运行gh-pages -d build
构建过程,然后运行npm run deploy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.