Closed jimlloyd closed 10 months ago
Hi, I've just managed to get it to work. The only thing required is to copy .env files to dist/app-name directory.
You can do this by modifying predeploy
section of firebase.app-name.json
as shown below.
...
"functions": {
"predeploy": [
"npx nx build app-name --with-deps",
"npx nx lint app-name",
"cp apps/app-name/src/.env dist/apps/app-name/.env",
"cp apps/app-name/src/.env.test dist/apps/app-name/.env.test",
"cp apps/app-name/src/.env.prod dist/apps/app-name/.env.prod"
],
"source": "dist/apps/app-name"
},
...
Thanks @wnuczek! In hindsight that should have occurred to me.
Also fixed in PR #137
I have been doing all of my development with a single development Firebase project and am now trying to use multiple Firebase projects. Firebase best practices recommends four types of projects: dev, test, staging, and prod. I am the sole developer for my application so I can probably get away for now with two projects, call them
dev
andalpha
, where I am treatingalpha
as a prod project that I will likely delete when I get closer to launching my product to the world.So lets's say I have two aliases:
dev
andalpha
pointing to two projects. I assume my.firebaserc
file should probably look like this:Firebase supports .env files as described here: https://firebase.google.com/docs/functions/config-env
So I should have three files
.env
,.env.dev
and.env.alpha
. But where should these files be placed in annx-firebase
project tree?I currently have provided them in the two obvious places: The root of the project, where the
firebase.json
andfirebase.functions.json
are located, and inside theapps/functions
directory. The Firebase doc above claims that I should see a message when deploying:I don't see the
Loaded environment variables
message when I deploy. It might be doing the right thing anyway, because my deployeddev
andalpha
projects are partly functional. Maybe the message is no longer logged?My deployed apps are now usable with Anonymous but not Google authentication -- I'll debug that separately.
While researching all of this I was reminded that Firebase supports local "demo" projects which are purely local, served by the emulators. These demo projects cannot be added to .firebaserc and used via
firebase use <alias>
, bit require that the--project demo-test
flag be passed to allfirebase
CLI command. Does nx-firebase provide any ways to make demo projects usable with the--project
option injected automatically?