Create multiple sites
Goto Firebase Console -> Hosting, then Advance -> Add another site.
Select a site name, also known as resource name.
Testing
Edit firebase.json.
- Change
hostingto array of objects. - Each hosting object should have a
targetfield (known astarget name). - Assign a different
publicdirectory for each hosting object
{ "hosting": [ { "target": "main", "public": "main/public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**", "**/public-*/**" ], "trailingSlash": false }, { "target": "app", "public": "app/public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**", "**/app/public-*/**" ], "rewrites": [ { "source": "/test", "function": "test" }, { "source": "**", "function": "nuxtssr" } ], "headers": [ { "source": "**/_nuxt/*.*", "headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000" }] } ], "trailingSlash": false } ],}Usage
firebase serve --only hosting:TARGET_NAMEor
firebase serve --only functions,hosting:TARGET_NAMEDeployment
Assign target name to resource name.
firebase target:apply hosting TARGET_NAME RESOURCE_NAMEThe command above will update .firebaserc
{ "projects": { "default": "PROJECT_ID" }, "targets": { "PROJECT_ID": { "hosting": { "TARGET_NAME": [ "RESOURCE_NAME" ], "TARGET_NAME02": [ "RESOURCE_NAME02s" ] } } }}Deploy
firebase deploy --only hosting:TARGET_NAMENOTE: Cloud functions are shared between multiple sites (actually, functions are independent from hosting). Each hosting site can has its own rewrites via firebase.json.