更多信息请查阅
create-react-app
生成的模板项目中的README.md
创建React项目
Step 1:
npm install -g create-react-app
全局安装create-react-app
Step 2:
create-react-app my-app
快速生成React模板项目
Step 3:
进入目录并预览项目1
2cd my-app
npm start
Step 4:
此时访问http://localhost:300
即可预览项目
React部署 - Gtithub Pages
Step 1:
在package.json
中添加homepage
配置1
2
3"homepage":"https://myusername.github.io/my-app"
//如果为Github Pages添加自定义域名则为
"homepage":"http(s)://mydomian/"
Step 2:
安装gh-pages
:1
2npm install --save gh-pages
yarn add gh-pages
Step 3:
在package.json
的scripts
中添加deploy
,即下面两行
1 | "scripts": { |
Step 4:
使用 npm run deploy
部署至github
1
npm run deploy
Step 5:
确保项目的 gh-pages
分支中Github Pages设置无误
Step 6:
自定义域名的CNAME
文件
在public/
目录下添加CNAME
文件,部署时自动上传至gh-pages
分支