最終更新:2023-05-26 (金) 08:46:50 (10d)
Cloud Functions for Firebase/開発
Top / Cloud Functions for Firebase / 開発
https://firebase.google.com/docs/functions/get-started?hl=ja
コマンド
TypeScript
package.json
{ "name": "functions", "scripts": { "build": "tsc", "build:watch": "tsc --watch", "serve": "npm run build && firebase emulators:start --only functions", "shell": "npm run build && firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "engines": { "node": "18" }, "main": "lib/index.js", "dependencies": { "firebase-admin": "^11.8.0", "firebase-functions": "^4.3.1" }, "devDependencies": { "typescript": "^4.9.0", "firebase-functions-test": "^3.1.0" }, "private": true }
Cloud Functions/エミュレータ
- このツールを使用するには、事前にコードをコンパイルする必要があります。
- firebase emulators:startまたはfirebase functions:shellを実行する前に、関数ディレクトリ内でnpm run buildを実行してください。
- あるいは、ショートカットとしてnpm run serveまたはnpm run shell?を実行します。
デプロイ
- firebase deployの実行時に、プロジェクトの index.ts が index.js にトランスパイルされます。