-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.env.[mode] files #571
Comments
What are the env var names in the env file? IIRC only those starting with VITE_ will be available |
|
I am experiencing this problem as well. When vite builds my PWA, it honors the
If you look at the output of This is currently very problematic for my build as it requires a lot of messing with dotenv files as I switch between build modes. I have found no easy workaround to force the mode I want for my SW. |
@userquin Repro with instructions: https://github.com/CodingDoug/vite-pwa-mode-repro |
@CodingDoug thx, I'll try to take a look later |
Does VitePWA support Vite's
.env.[mode]
files?https://vitejs.dev/guide/env-and-mode.html#env-files
I tried creating a very simple Vite react app (
yarn create vite my-react-app --template react-ts
) and installed VitePWA. My service worker has a log forimport.meta.env
to see what variables are passed in. I created a.env.devAPI
file in the root of the project with an environment variable I want to specify. I added a command in my package.json"build:devAPI": "vite --mode devAPI build"
. When run, in the main code I can see my added environment variable. However, in the service worker code I do not see it.If instead I just add environment variables to a
.env
file, they do appear in the service worker. I guess this.env.[mode]
is not supported by VitePWA.The text was updated successfully, but these errors were encountered: