1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ReactをGitHub PagesにDeployする

Posted at

React を GitHub Pages にデプロイする方法はネット上に記事がたくさんありますが、どうもうまくできませんでした。

そこで、自分がうまくできた方法をまとめておきます。

実際のページ


手順

1. react-app を作成する

npx create-react-app site

2. GitHub リポジトリを作成 & clone
3. siteの内容をローカルリポジトリに移動する

mv site/* local-repository/

4. gh-pagesをインストール

npm install gh-pages

5. package.json内のscriptsを変更
以下の2行を追加する

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

6. デプロイする

npm run deploy

7. リポジトリの設定を変更
GitHub のサイトから、
settings -> pagesに行き、

  • Sourceを Deploy from a branch
  • Branchをgh-pages/(root)にする。

これで自分はDeployできました
既存の方法でうまくいかない場合は、試す価値があると思います。
~Thank you for leading~

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?