Skip to content

Mode Support for Vite Deployments #8471

Closed
@hkropp

Description

@hkropp

I have a vite app and would like firebase to support different modes during deployment.

Vite uses modes to pick up environment variables like so:

.env                # loaded in all cases
.env.local          # loaded in all cases, ignored by git
.env.[mode]         # only loaded in specified mode
.env.[mode].local   # only loaded in specified mode, ignored by git

From the vite documentation: https://vite.dev/guide/env-and-mode#env-files

In my case, the Firebase API key among other variables is defined inside the .env.[mode] configuration files.

So that, if I deploy to staging or production, it would be great to be able to define the mode during firebase deploy --only hosting such that the right configuration is picked up.

Currently, one gets the following warning if changing the build command in package.json:

WARNING: Your package.json contains a custom build that is being ignored. Only the Vite default build script (e.g, "vite build") is respected. If you have a more advanced build process you should build a custom integration https://firebase.google.com/docs/hosting/express

It would be great if the vite modes and the defined environments in .firebaserc would be the same. So, in case of using firebase use ENV, which would also be the selected build mode for vite.
This behavior would be similar to the current behavior using the Firebase emulator, where the development mode is being used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions