DEV Community

Sai Varun Tangalla
Sai Varun Tangalla

Posted on

How to build a React App and Deploy for Production

Step-by-Step Procedure:

  1. Create a React App using Create-React-App
  2. After working on the project, we need to make some changes for package.JSON file
  3. Changes to make in package.JSON file: Add HomePage script, Homepage to refer to source control you will be deploying your project. If you are deploying to Github then it will be "https://username.github.io/repositoryname
  4. Create a GitHub Repository
  5. Add the gh-pages package to your project(using cmd npm add gh-pages)
  6. We also need to add predeploy and deploy scripts in pacakge.JSON file
  7. "predeploy":"npm run build" and "deploy" : "gh-pages -d build"
  8. Re-intialize Git repository, Add everything for commit and push the files to the master branch
  9. Please use the following cmds: git init git add . git commit -m "first commit" git remote add origin remote repository URL git remote -v git push -u origin master 10.Create gh-pages branch other than master 11.Now in the terminal run cmd npm run deploy, to finish the deployment

Top comments (0)