firebase
hosting
安裝最新版的 nodejs
(如有權限問題就在前面加上 sudo,或Fixing npm permissions)安裝 global firebase-tools
npm install -g firebase-tools
建立資料夾
mkdir firebase_test
cd firebase_test
登入
firebase login
user$ firebase login ? Allow Firebase to collect anonymous CLI usage information? Yes Visit this URL on any device to log in: https://accounts.google.com/o/oauth2/auth?client_id=.... Waiting for authentication... ✔ Success! Logged in as [email protected]
初始化
firebase init
user$ firebase init 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 You're about to initialize a Firebase project in this directory: /PATH/firebase_test Before we get started, keep in mind: * You are initializing in an existing Firebase project directory ? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices. ⚠ You have have not selected any features. Continuing will simply associate this folder with a Firebase project. Press Ctrl + C if you want to start over. === 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: Project (project-00000) i Writing configuration info to firebase.json... i Writing project information to .firebaserc... ✔ Firebase initialization complete!
開啟 local 主機
firebase serve
user$ firebase serve === Serving from '/PATH/firebase_test'... i hosting: Serving hosting files from: app ✔ hosting: Local server: http://localhost:5000
修改 firebase.json
1 { 2 "hosting": { 3 "public": "app", => add 改成 public 4 "ignore": [ 5 "firebase.json", 6 "**/.*", 7 "**/node_modules/**" 8 ] 9 } 10 }
建立 index.html 在 ./public 資料夾
user$ mkdir public user$ cd public user$ vi index.html
部署
firebase deploy
user$ firebase deploy === Deploying to 'project-00000'... i deploying hosting i hosting: preparing public directory for upload... ✔ hosting: 1 files uploaded successfully i starting release process (may take several minutes)... ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/project-00000/overview Hosting URL: https://project-00000.firebaseapp.com
firebase deploy --only hosting
只部署 hosting
切換不同的 project
firebase use
functions