CLASSFUNC BLOG
We Share Our Knowledge
Deploy Firebase Hosting cho dự án mới
Lê Thành
14 Th08 2020 08:54
  1. Chọn hosting bằng lệnh firebase init
  2. [ ở firebase console ] tới hosting -> Add another site
firebase target:apply hosting [added-site] [added-site]

Kiểm tra .firebaserc/targets có trường [added-site] chưa.

Ví dụ: .firebaserc

{ "projects": { "default": "classfunc-com" }, "targets": { "classfunc-com": { "hosting": { "blogs-classfunc": [ "blogs-classfunc" ] } } } }
  1. Thêm vào firebase.json/hosting trường target với giá trị [added-site] ở trên Ví dụ: firebase.json
{ "hosting": [ { "target": "blogs-classfunc", "public": "out", "ignore": [ "firebase.json", "*/.", "*/node_modules/*" ], "cleanUrls": true, "rewrites": [ { "source": "/", "destination": "/index.html" } ], "headers": [ { "source": "index.html", "headers": [ { "key": "Cache-Control", "value": "max-age=0, no-cache" } ] }, { "source": "**/*.@(jpg|jpeg|gif|png)", "headers": [ { "key": "Cache-Control", "value": "public,max-age=604800" } ] }, { "source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)", "headers": [ { "key": "Access-Control-Allow-Origin", "value": "*" }, { "key": "Cache-Control", "value": "public,max-age=604800" } ] } ] } ] }
  1. Deploy
firebase deploy --only hosting:[added-site]
  1. 🍻

Xem thêm:

hosting multisites