LoginSignup
34
26

More than 1 year has passed since last update.

GitHub Pages でReact Appを公開

Last updated at Posted at 2020-01-03

はじめに

create-react-appで作成したアプリをGitHub Pagesで公開してみます。

リポジトリの作成

$ yarn create react-app myapp --template typescript
$ cd myapp
$ git commit -m "first commit"
$ git remote add origin git@github.com:pure-adachi/myapp.git
$ git push -u origin master

gh-pagesでデプロイ

gh-pagesインストール

$ yarn add -D gh-pages
package.json
  // ...
  "homepage": "http://pure-adachi.github.io/myapp",
  "scripts": {
    // ...
    "deploy": "yarn build && gh-pages -d build"
  },

デプロイ

$ yarn deploy

何度かパスワードを聞かれました。

コミット&プッシュせずに、更にはmasterブランチですがデプロイ出来ました。

自動でgh-pagesブランチが作成されて、GitHub Pagesのブランチ設定も行われます。

-bオプションでブランチの指定が出来ますが、Github Pagesで配信可能なブランチはmastergh-pagesなので
デフォルトのgh-pagesブランチを使うことにしました。

スクリーンショット 2020-01-03 22.34.05.png

http://pure-adachi.github.io/myapp にアクセスすると動作が確認出来ました。

スクリーンショット 2020-01-03 22.34.49.png

終わりに

簡単に出来ましたね

参考文献

34
26
1

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
34
26