Update User Guide with deploying to GitHub User pages (#3510)

This commit is contained in:
Aaron Lamb
2017-11-27 13:28:42 -08:00
committed by Joe Haddad
parent 733ba3ab41
commit 770fdf4ba1

View File

@@ -2012,12 +2012,18 @@ For more information see [Add Firebase to your JavaScript Project](https://fireb
**The step below is important!**<br>
**If you skip it, your app will not deploy correctly.**
Open your `package.json` and add a `homepage` field:
Open your `package.json` and add a `homepage` field for your project:
```js
```json
"homepage": "https://myusername.github.io/my-app",
```
or for a GitHub user page:
```json
"homepage": "https://myusername.github.io",
```
Create React App uses the `homepage` field to determine the root URL in the built HTML file.
#### Step 2: Install `gh-pages` and add `deploy` to `scripts` in `package.json`
@@ -2048,6 +2054,18 @@ Add the following scripts in your `package.json`:
The `predeploy` script will run automatically before `deploy` is run.
If you are deploying to a GitHub user page instead of a project page you'll need to make two
additional modifications:
1. First, change your repository's source branch to be any branch other than **master**.
1. Additionally, tweak your `package.json` scripts to push deployments to **master**:
```diff
"scripts": {
"predeploy": "npm run build",
- "deploy": "gh-pages -d build",
+ "deploy": "gh-pages -b master -d build",
```
#### Step 3: Deploy the site by running `npm run deploy`
Then run: