Skip to content

Instantly share code, notes, and snippets.

View ZaneMeroff's full-sized avatar

Zachary Nemeroff ZaneMeroff

View GitHub Profile

Deploying a React App* to GitHub Pages

* created using create-react-app

Introduction

In this tutorial, I'll show you how I deployed a React app—which I created using create-react-app—to GitHub Pages.

You can visit the deployed app, at https://gitname.github.io/react-gh-pages/.

How to deploy React app to GitHub Pages

Install the gh-pages package as a "dev-dependency" of the app.

$ npm install gh-pages --save-dev
  • The commands shown in the following steps can all be issued from within the app's folder.

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

For Vue create a new file in your project root named vue.config.js (Docs) and specify the publicPath (Docs).

NOTE if using a custom subdomain like http://project-name.your-domian.com change publicPath to '/'

module.exports = {
  publicPath: '/name-of-your-project/'
}
  1. Now commit and push your changes and run npm run build

Git Styleguide

Feature Branch Names

Feature branch names should start with the developers initials, followed by a / character, and then a descriptive snake case string, e.g.:

ed/this_is_a_new_feature

Do not use camel case for branch names please!

@ZaneMeroff
ZaneMeroff / remove_remote_squash_history.md
Created September 11, 2021 15:16
Remove remote and squash git history

Remove local remote

git remote remove origin

Squash all git history into one commit

git checkout --orphan some-branch
git commit -m "First commit"
git branch -f master