Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

how to build and deploy a react app to github pages

/*first things first we need to install node.js and npm then executing the command
"npm install gh-pages --save-dev" //!:usually when we need to update we need to re build and deploy so we repeeat from here
in the root directory of your react app
finaly do as follow*/
{//found in package.json
  //add the below line 
"homepage": "http://{github User Name}.github.io/{repo name}",
  //
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {        
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
  //add 2 lines below
"test": "react-scripts test",
"eject": "react-scripts eject"
  //
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
1,
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
},
"devDependencies": {
"gh-pages": "^2.0.1"
}
//finishing with this command in root directory of the react app 
//npm run deploy 
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #build #deploy #react #app #github #pages
ADD COMMENT
Topic
Name
3+7 =