iT邦幫忙

2026 iThome 鐵人賽

DAY 4
0
Build on Google AI

從 Vibe Coding 到 Production:用 Google AI 打造上線守門員系列 第 4

Day 4|動手建立 Demo:用 Firebase 完成登入、資料庫與部署基礎

  • 分享至 

  • xImage
  •  

昨天,我們規劃了 Vibe Guard 的架構與測試題目。今天要把第一版產品跑起來。

這一版提供三項功能:

  1. 使用 Email 和密碼建立測試帳號。
  2. 把專案名稱與上線目標寫入 Cloud Firestore。
  3. 透過 Firebase Hosting Emulator 提供前端網頁。
    我們先使用 Firebase Local Emulator Suite,不連接正式雲端專案。Emulator 可以模擬 Authentication、Firestore 與 Hosting,也能在本機測試 Security Rules。

為什麼先使用 Emulator?


直接連接正式環境會增加三項風險。測試資料可能污染正式資料庫,錯誤規則可能公開資料,重複測試也可能產生費用。

Emulator 把這些操作留在本機。我們可以刪除資料、修改規則並重新啟動,不會影響真實使用者。

Emulator 不是正式環境。它適合開發與測試,但不能證明部署後的 IAM、網路、配額與雲端設定完全正確。

今天使用的專案


專案已放在:
/media/mickey/777/ithome/demo-app

https://ithelp.ithome.com.tw/upload/images/20260823/20121335NGmvFSGulL.png

步驟一:安裝套件
進入專案並安裝相依套件:

cd /media/mickey/777/ithome/demo-app
npm install

專案使用 Firebase Web SDK、Firebase CLI 與 Vite。Firebase Emulator 的 Firestore 元件需要 Java。本機目前已有 Node.js 24、npm 11 與 Java 21。

步驟二:建置前端
npm run build
Vite 會把網站輸出到 dist。Firebase Hosting Emulator 接著會提供這個目錄。

實際驗證結果:專案已成功建置。Vite 轉換 21 個模組,並產生 HTML、CSS 與 JavaScript 檔案。

步驟三:啟動 Firebase Emulator
npm run emulators
第一次啟動時,Firebase CLI 會下載 Firestore Emulator 與 Emulator UI。看到 All emulators ready 後,再開啟以下網址:
https://ithelp.ithome.com.tw/upload/images/20260823/20121335a467aeVQS1.png


上一篇
Day 3|從零規劃靶場:Demo 專案要藏入哪些 Production 問題?
系列文
從 Vibe Coding 到 Production:用 Google AI 打造上線守門員4
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言