Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erabossid/react-gh-pages

Deploy your react-app to gh-pages
https://github.com/erabossid/react-gh-pages

deploy gh-pages reactjs

Last synced: about 1 month ago
JSON representation

Deploy your react-app to gh-pages

Awesome Lists containing this project

README

        

# Deploy your React App to gh-pages

Bootstrapped by `create-react-app`

## Make an empty repo on github (no file)

## Install the app using this command

```javascript
npx create-react-app yourprojectname
```
## Go to your project

```javascript
cd yourprojectname
```

## Intall gh-pages

```javascript
npm install gh-pages
```
## Add a homepage to `package.json`

```javascript
"homepage":"https://yourgithubusername.github.io/yourprojectname"

// example:
"homepage":"https://tradecoder.github.io/react-gh-pages"
```

## Add the following code to the script section of `package.json`

```javascript
"predeploy":"npm run build",
"deploy":"gh-pages -d build"
```

If you do not delete any code from the package.json file from the script,
your code may look like this after adding the above properties

```javascript
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy":"npm run build",
"deploy":"gh-pages -d build"
}
```

## Create a git repo

```javascript
git init
```

## Add your github project remote url

```javascript
git remote add origin https://github.com/yourgithubusername/yourprojectname.git

// We are adding our own

git remote add origin https://github.com/tradecoder/react-gh-pages
```

## Setup is ok, now deploy your app to github gh-pages

```javascript
npm run deploy
```
Visit your project using the homepage you set earlier

## Upload the source code to github
Add all the changes in your project

```javascript
git add --all
```
Commit with a message

```javascript
git commit -m 'your message here'
```
Push your source codes to your github project

```javascript
git push origin master
```
Source code uploaded to your github master branch

## Done