Closed6
SvelteKit + Firebase に入門

SvelteKitのFirebase Adapterを使ってみる

まずインストール
$ npm i -D svelte-adapter-firebase
$ npm i -D firebase-tools
firabase-toolsはnode.js v14までの対応の模様
$ nvm install 14
$ npx firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/pi/work/svelte-app
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choice
s.
◯ Database: Configure Firebase Realtime Database and deploy rules
◉ Firestore: Deploy rules and create indexes for Firestore
◉ Functions: Configure and deploy Cloud Functions
◉ Hosting: Configure and deploy Firebase Hosting sites
◉ Storage: Deploy Cloud Storage security rules
◉ Emulators: Set up local emulators for Firebase features
❯◉ Remote Config: Get, deploy, and rollback configurations for Remote Config

自分の環境では別プロジェクトで npx firebase login
済みでした。

$ npm run dev
で開発サーバーが起動。

firebase adapterのセットアップガイドに従って設定を調整する
調整後、以下のコマンドでビルド$ npm run build
あとは firebase deploy
コマンドでデプロイ
$ npx firebase deploy
ただし、SvelteはFunctions or CloudRunを使うので、Blazeプランが必須!

Firebaseにはadapter-staticで静的なサイトにしてHostingにするのがいいのかもしれない。
このスクラップは2021/06/09にクローズされました