xxxxxxxxxx
npm install gh-pages --save-dev
package.json
//...
"homepage": "http://gitname.github.io/react-gh-pages"
//...
"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
git init
xxxxxxxxxx
npm install gh-pages --save-dev
package.json
//...
"homepage": "http://gitname.github.io/react-gh-pages"
//...
"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
git init
git remote add origin https://github.com/gitname/react-gh-pages.git
npm run deploy
git add .
git commit -m "Create a React app and publish it to GitHub Pages"
git push origin master
xxxxxxxxxx
step-1: open package.json file and add this:
"homepage": "https://myusername.github.io/my-app",
step-2: install github pages form your terminal:
npm install --save gh-pages
step-3: add the following scripts in- scripts field in- package.json:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
step-4: push all changes to git:
git add
git commit -m "your commit"
git push
step-5: Now final command:
npm run deploy
Notes: read(https://create-react-app.dev/docs/deployment/#github-pages)
watch(https://youtu.be/Q9n2mLqXFpU?t=545)
xxxxxxxxxx
In package.json add the following in this order:
"homepage": "https://{your-github-name}.github.io/{name-of-your-repo}"
in the Scripts section, add:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
Save and commit Changes.
Push your changes to github.
Finally, in the terminal run:
npm run build
Your react app will be successfully deployed to github pages