万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・寄付お願いします
    YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
    BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
    c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1

Nuxt.jsとFirebaseでSPA×SSR×PWA×サーバーレスを実現するの記事のメモ

https://inside.dmm.com/entry/2018/04/10/nuxt-firebase

// サーバー起動
$ npm run start

をする時、Projectトップではない。 srcの中

firebase initのメモ

You're about to initialize a Firebase project in this directory:

  /Users/shinriyo/development/vue_apps/proj_name

? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices. Functions: Con
figure and deploy Cloud Functions

=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

? Select a default Firebase project for this directory: [don't setup a default project]

=== Functions Setup

A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.

? What language would you like to use to write Cloud Functions? TypeScript
? Do you want to use TSLint to catch probable bugs and enforce style? Yes
? File functions/package.json already exists. Overwrite? No
i  Skipping write of functions/package.json
✔  Wrote functions/tslint.json
✔  Wrote functions/tsconfig.json
✔  Wrote functions/src/index.ts
? Do you want to install dependencies with npm now? No

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!

publicは作られなかった・・。 ので

mkdir public/
mkdir public/assets

をしてから以下のことをした

// あらかじめpublicディレクトリの中をクリーンアップ
$ rm -rf public/*

// ビルド時に生成された静的ファイルを設置
$ cp -R functions/nuxt/dist/ public/assets

// 用意していた静的ファイルを設置
$ cp -R src/static/* public

デプロイの時 firebase serve --only hosting,functions

このエラー

Error: No project active. Run with --project <projectId> or define an alias by
running firebase use --add

このQiita記事の真似する

qiita.com

ここでプロジェクト作って Sign in - Google Accounts

addする。

そのあとデプロイ

firebase deploy

⚠  functions: package.json indicates an outdated version of firebase-functions.
 Please upgrade using npm install --save firebase-functions@latest in your functions directory.
⚠  functions: Please note that there will be breaking changes when you upgrade.
 Go to https://firebase.google.com/docs/functions/beta-v1-diff to learn more.

=== Deploying to 'nuxttest-eed13'...

i  deploying functions, hosting
i  functions: ensuring necessary APIs are enabled...
⚠  functions: missing necessary APIs. Enabling now...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (372.15 KB) for uploading


There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
⚠  functions: Upload Error: HTTP Error: 503, The service is currently unavailable.

firebase deployで失敗したがもう一度firebase deployやったらなんかうまくいった。