I have the following structure (to handle different theming) using different websites on Firebase.
/src
/theme-1/index.html
/theme-2/index.html
All the "juice" is within src
and the file index.html
is the same for both theme-1
and theme-2
with exception of the line where I refer to the .css
file, where I use actually a different on.
For the moment, I only configured one target but I will add more in my firebase.json
:
{ "hosting": {
"target": "theme-1",
"public": "theme-1",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{"source": "**","destination": "/theme-1/index.html"}
],
"cleanUrls": true,
"headers": [ {
"source": "**",
"headers": [ {
"key": "Cache-Control",
"value": "max-age=60"
} ]
} ]
}
}
I then configure my target using the cmd commands to point to my firebase site:
firebase target:apply hosting theme-1 theme-1
and subsequently deploy the website:
firebase deploy
However, when I visit the page (despite it working locally), it seems not to be able to find the root folder /src (404 error).
How can I also include the folder /src in my deployment such that it works in the same way?
Only the directory specified by public
is deployed to Firebase. The name is slightly misleading because there are no "private" files/directories.
So you have to do "public": "src"
(or "public": "."
if you want to deploy the theme
directories as well), and adjust the other properties accordingly.