- Chọn hosting bằng lệnh
firebase init
- [ ở 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" ] } } } }
- Thêm vào
firebase.json/hosting
trườngtarget
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" } ] } ] } ] }
- Deploy
firebase deploy --only hosting:[added-site]
- 🍻