Install the gh-pages package from npm. You can use npm install -D gh-pages
or yarn add -D gh-pages
the package will help you to create a gh-pages branch on Github and also serve our bundled react files on this branch.
Edit the package.json
of your project and add a line
"homepage": "http://{user}.github.io/{repo}"
where {user} is your GitHub username, and {repo} is the name of the GitHub repository
you can now add the pre-deploy
and deploy
scripts to build & publish your project
"scripts": {
//...
"predeploy": "react-scripts build",
"deploy": "gh-pages -d build"
}
To publish your app to Github pages you can now use
npm run deploy
or yarn run deploy