Instruction for setting up firebase hosting.
- Create a github account
- Create a firebase account
- Go to a Firebase Console (https://console.firebase.google.com/) and create a new project
- On a local instance go to a console and run "npm install -g firebase-tools"
- Run "firebase login" to login into your account.
- Run "firebase init hosting"
a) choose "Use an existing project"
b) select the created project
c) "What do you want to use as your public directory" - skip, "public" by default
d) "Configure as a single-page app" - y
e) "Set up automatic build and deploys- with GitHub" - y
f) type existed repository using format "user/repository"
g) "Set up wotkflow to run a build script before every deploy" - y
h) "What script should be run before every deploy" - choose default - "npm ci && npm run build"
i) "Set up autpmatic deployment to your site's live channel when a PR is a merged" - y
j) "What is the name of the GitHub branch associated with your site's live channel" - choose default - "main"
For handling multiple environments:
- Go to a Firebase Console (https://console.firebase.google.com/) -> Hosting -> Add another site
- Add a website id, e.g. "staging-website"
- Update firebase json by adding a new site for "staging-website" and corrected main website. "site" should be equal to your site ID in firebase. e.g.
{
"hosting": [{
"site": "production",
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}, {
"site": "staging-website",
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}]
}