github挂载React项目
####1.在github上创建仓库
创建一个普通的仓库就可以
####2.将本地代码上传到github上去
- 进入到本地代码目录文件
- 点击git bash
- 执行如下命令
git init
git add .
git commit -m “first commit” (first commit 本次提交的内容)
git remote add origin https://github.com/XXX.git (自己新建的仓库地址)
git push -u origin master (这一句执行的时候 ,需要根据提示输入你的 github 账号 和密码)
###4.修改本地React项目的 package.json文件
1.配置homepage:
修改你的github仓库地址,例如我的https://github.com/songbl/React-app
“homepage”: “https://songbl.github.io/React-app”, 配置的访问路径
2.配置发布选项
“predeploy”: “npm run build”,
“deploy”: “gh-pages -d build”
predeploy:是将你的项目预编译成静态文件放在build文件夹
deploy:是使用gh-pages 部署你的build文件夹下的内容
####5.安装 gh-pages
npm install gh-pages --save-dev
####6.部署项目到github page上
npm run deploy
####出现下图,就Ok了