Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Deploying React apps to Github Pages

I’ve been struggling with getting my various portfolio projects deployed lately. However, I do believe I’ve got deployment to Github Pages down pat. Thankfully it’s really straightforward, so I’ll keep the to-do list brief.

  1. Install the gh-pages NPM package.
    npm install --save-dev gh-pages
  2. Update your repository’s package.json with these lines:
    "homepage": "https://[your Github username].github.io/[your Github repository]"
    and under “scripts”:
    "deploy" : "npm run build&&gh-pages -d build"
  3. Build the app. The build command will likely be one of these:
    npm run build
    react-scripts build
    webpack
  4. Deploy the app.
    npm run deploy
  5. Over on your Github repository’s settings page, under Github Pages, ensure ‘source’ is set to ‘gh-pages branch’.



This post first appeared on Dented Nerd, please read the originial post: here

Share the post

Deploying React apps to Github Pages

×

Subscribe to Dented Nerd

Get updates delivered right to your inbox!

Thank you for your subscription

×