Allow Firebase project root to be configured independently of firebase.json location
The Firebase CLI currently appears to treat the directory containing "firebase.json" as the effective root directory for the Firebase project.
While "--config" allows "firebase.json" itself to be moved, moving the config file also changes how relative paths inside that configuration are resolved.
This creates an awkward limitation for monorepos, where configuration files may naturally live in an infrastructure/configuration directory while build artifacts remain at the workspace root.
It would be useful if the Firebase CLI allowed the configuration file location and the project root to be specified independently.
Example
Consider an Nx monorepo structured like this:
repo/
├── apps/
├── libs/
├── dist/
│ └── apps/
│ └── web/
├── infrastructure/
│ └── firebase/
│ ├── firebase.json
│ ├── firestore.rules
│ ├── firestore.indexes.json
│ └── storage.rules
├── nx.json
└── package.json
From an organizational standpoint, keeping Firebase-specific infrastructure under:
infrastructure/firebase/
is desirable.
The CLI supports selecting that file:
firebase deploy --config infrastructure/firebase/firebase.json
However, if the Hosting configuration contains:
{
"hosting": {
"public": "dist/apps/web"
}
}
the path is effectively resolved relative to:
infrastructure/firebase/
rather than the actual workspace root.
The build output produced by Nx is located at:
repo/dist/apps/web
so moving "firebase.json" also unintentionally changes the filesystem context of the Firebase project.
Current workaround
The practical workaround is to leave "firebase.json" at the workspace root:
repo/
├── firebase.json
├── apps/
├── libs/
├── dist/
└── infrastructure/
└── firebase/
├── firestore.rules
├── firestore.indexes.json
└── storage.rules
and then reference Firebase-specific files from the root configuration.
This works, but it means "firebase.json" becomes a special root-level file purely because its location controls the CLI's filesystem context.
In larger monorepos, that makes Firebase configuration harder to organize consistently with other infrastructure.
Proposed behavior
It would be useful to provide a way to explicitly specify the Firebase project root separately from the config file.
For example, a CLI option:
firebase deploy \
--config infrastructure/firebase/firebase.json \
--project-root .
or perhaps a configuration property:
{
"root": "../../",
"hosting": {
"public": "dist/apps/web"
}
}
The exact API is less important than allowing these two concepts to be independent:
- Location of "firebase.json"
- Root directory used for resolving project-relative paths
Why this matters
This becomes particularly useful in monorepos using tools such as Nx, where:
- application source lives under "apps/"
- shared code lives under "libs/" or "packages/"
- build artifacts are emitted to a workspace-level "dist/"
- deployment/infrastructure configuration may live under "infrastructure/"
In that structure, the location of a Firebase configuration file is an organizational concern and doesn't necessarily represent the root of the application workspace.
Separating the config location from the project root would make Firebase CLI behavior more flexible without changing the existing default behavior.
Backwards compatibility
Existing behavior could remain unchanged when no explicit project root is supplied.
For example:
firebase deploy
would continue using the directory containing "firebase.json" as it does today.
Only users who explicitly provide a root would get the new behavior.
Additional context
I initially expected "--config" to control only which Firebase configuration file was loaded.
The surprising part was discovering that relocating the configuration also effectively relocates the filesystem context used by Firebase.
A separate root option would make "--config" much more useful for monorepo and infrastructure-oriented repository layouts.