Skip to content

Instantly share code, notes, and snippets.

@mikoloism
Last active June 4, 2021 13:44
Show Gist options
  • Save mikoloism/2f958ca7f3e193e0ccb4166de9e504a5 to your computer and use it in GitHub Desktop.
Save mikoloism/2f958ca7f3e193e0ccb4166de9e504a5 to your computer and use it in GitHub Desktop.
How deploy create-react-app with gh-pages

How deploy create-react-app with gh-pages

gh-pages is a npm packge help developers to deploy they app on github-pages

steps

1. install

TIPS : this installation should be on home path folder (cd ~ or cd)

npm i -g create-react-app
# or
npm install -g create-react-app

2. create-react-app

npx create-react-app {APP_NAME} --use-npm
cd {APP_NAME}

3. install gh-pages

npm i -D gh-pages
# or
npm install --save-dev gh-pages

4. config package.json

add below (if not exist or not standard) to your package.json file

{
  "homepage": "https://{YOUR_GITHUB_USERNAME}.github.io/{REPOSITORY_NAME}",
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
  }
}

5. run command

npm run deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment