- 安装
gh-pages
:
npm install gh-pages --save-dev
-
package.json
添加 :
"homepage": "https://myusername.github.io", myusername 是你的 github 名
"scripts": {
+ "predeploy": "npm run build",
+ "deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
- 在本地项目中运行:
npm run deploy
- 在浏览器里访问
https://myusername.github.io/项目名
网友评论