Skip to content

Instantly share code, notes, and snippets.

@mahendra0859
Last active February 8, 2021 19:20
Show Gist options
  • Save mahendra0859/21759705cd359d830b12ec9076de5865 to your computer and use it in GitHub Desktop.
Save mahendra0859/21759705cd359d830b12ec9076de5865 to your computer and use it in GitHub Desktop.
Deploying React App

Methods to deploy react app

Method 1: For static react app

$ npm run build
$ mv ./build ./docs
$ git add . && git commit -m "commit" && git push

* In GitHub Pages for source select 'master branch /doc folder`

Method 2: Using gh-pages package

$ npm install gh-pages --save-dev
$ npx json -I -f package.json -e "this.homepage='http://{username}.github.io/{repo-name}'"
$ npx json -I -f package.json -e "this.scripts={...this.scripts,'predeploy':'npm run build','deploy':'gh-pages -d build'}"
$ git init
$ git remote add origin git@github.com:Yuribenjamin/my-app.git
$ npm run deploy

Method 3: Using gh-pages package

$ npm install netlify-cli -g
$ netlify login
$ netlify deploy

Method 4: Using Firbase

  • To log in to Firbase
$ firebase login
  • To initialize firebase setup
$ firebase init
  • selecte the hosting option
  • Select the existing project or create a new one in firebase

  • add 'build' folder as public diectory

  • and 'yes' SPA configuration

  • create .firbaserc and firebase.json file

  • To deploy the build to firbase
$ npm run build

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