LoginSignup
7
11

More than 5 years have passed since last update.

Gatsby+firebaseで独自ドメインのHTTPSサイトを作る(その3 Gatsbyの設定)

Last updated at Posted at 2018-05-07

はじめに

(ほぼ)無料で静的サイトを簡単に作れたらいいなと常々おもっていました。
最近は環境などそろってきたのでやってみます。

今回は「Gatsbyの設定」です。

前提条件

  • Cloud9を使って作業
  • お名前.comにアカウントあり
  • Firebaseのアカウントあり

Gatsbyのインストール

nodeのツールのため、npmでインストールします。

npm install -g gatsby

Gatsbyプロジェクト作成

その2で作成したフォルダは利用せず、新しいフォルダにプロジェクトを作成します。
ブログのテンプレートを利用します。

cd ~/workspace
gatsby new blog https://github.com/gatsbyjs/gatsby-starter-blog

Gatsby動作確認

動作確認を行います。

cd blog
gatsby develop -H $IP -p $PORT

上記実行後、以下が表示されるため、クリックします。

  Local:            http://0.0.0.0:8080/

うまく英語のブログが表示されたらOKです。

ビルド

デプロイ用にビルドをします。

gatsby build

デプロイ

firebaseのファイルを設定します。

その2で作成したファイル2本をコピーします。

cp ../gatsby-test/.firebaserc .
cp ../gatsby-test/firebase.json .

firebase.jsonを修正します。
publicを"./"から"public"に修正
rewriteを削除

firebase.json
{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

デプロイします。

firebase deploy

以上で完成です!!

作成したドメインにアクセスしてみてください。

なお、gatsbyはこちらを参考にしました。

7
11
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
7
11