8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Nuxt.js x Firebase x SSRをワンコマンドでビルド

Last updated at Posted at 2018-04-14

経緯

現在個人で作っているNuxt.js x Firebase x SPAのサイトをSSR対応する際に
ちょうどよく、Nuxt.jsとFirebaseでSPA×SSR×PWA×サーバーレスを実現する
の記事が掲載。記事どおりの対応で成功。感謝。

この記事はそのうえでbuild & deployを
yarn run releaseのみで対応できたのでメモがわりに。

ご指摘あればよろしくお願いします。

todo

1. package.json作成

project rootのターミナルにて

# package.jsonの作成
$ yarn init

# npm追加
$ yarn add cpx mkdirp npm-run-all rimraf

2. package.jsonにscript等追記

{
  ....,
  "private": true,
  "scripts": {
    "release:install:src": "cd src && yarn install && cd ../",
    "release:install:functions": "cd functions && yarn install && cd ../",
    "release:build": "cd src && yarn run build && cd ../",
    "release:clean": "rimraf ./public/*",
    "release:copy:build": "cpx \"./functions/nuxt/dist/**\" ./public/assets",
    "release:copy:static": "cpx \"./src/static/**\" ./public",
    "release:deploy": "firebase deploy",
    "release": "npm-run-all -s release:build release:clean release:copy:build release:copy:static release:deploy"
  },
  "engines": {
    "node": "6.11.5",
    "npm": ">= 3.10.10"
  },
  "dependencies": {
    "cpx": "^1.5.0",
    "mkdirp": "^0.5.1",
    "npm-run-all": "^4.1.2",
    "rimraf": "^2.6.2"
  }
}

一応enginesも追記。firebase Functionに合わせとく。

3. 完成 & 実行

この状態で

$ yarn run release

で正しくdeployされるはずです。イエーイ。

雑感

  • cd src && yarn install && cd ../頭悪そう。shellもっと使えるようになりたい
  • releseコマンド内長い
  • yarn workspaceとかlernaで綺麗に実現できるのか?今やるには学習コスト高い。
  • SSR表示まで重い。チューニングいる。
8
6
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
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?