$ npm install gh-pages --save-dev
- The commands shown in the following steps can all be issued from within the app's folder.
- At the top level, add a
homepageproperty. Define its value to be the stringhttp://{username}.github.io/{repo-name}, where{username}is your GitHub username, and{repo-name}is the name of the GitHub repository you created in step 1. Since my GitHub username isgitnameand the name of my GitHub repository isreact-gh-pages, I added the following property:
"homepage": "http://gitname.github.io/react-gh-pages"
- In the existing
scriptsproperty, add apredeployproperty and adeployproperty, each having the values shown below:
"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
$ git add .
$ git commit -m "Add to gh pages"
$ git push origin master
$ npm run build
$ npm run deploy
- your project should now be available at the address in your package.json file under the value of the "homepage" key
NOTE: It can take several minutes for your code to upload to GH servers after running the deploy command