Deploy React App in GitHub Pages
Deploy your create-react-app to GitHub pages.
Step 0: 📢📢
I am assuming you have installed all these on your system.
1. GitHub Account
2. Git installed on your system.
3. Node J.S ( Latest Stable Version)
Step 1: Let's Get Started 😏😏😏
$ create-react-app myapp
Step 2: I have Git Powers 😎😎😎
$ cd myapp
$ npm i gh-pages --save-dev
Step 3: Little bit more work 😬😬😬
Now you need to open package.json file and add on the top of the file.
'homepage':'"http://{username}.github.io/{repo-name}"'
Replace {username} with your github username and {repo-name} with respective repository name.
Step 4: This is magic 😲😲😱
Now in package.json file under existing scripts property we to need to add the following:
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
//...}
Step 5: You made it, 🥺🎉🎉🎉
After you push these changes to your GitHub repository. Run the following command.
npm run deploy
This will create a branch named GH-pages which will host your app. Under repository settings, you may make custom changes
Hope you enjoyed it.
Write to us,
theupweb@gmail.com