-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Wrong environment prefix. It should be PUBLIC_
instead of VITE_
#42
Comments
can you try changing the vite entry in your astro config file? vite: {
envPrefix: 'PUBLIC_'
} |
can you provide a minimal repo with the custom sw? |
I tried but it didn't work :( |
Here: https://github.com/Eptagone/astro-vitepwa-envprefix-test I also discovered a strange thing. The This is a video. In development, it works as expected. The PUBLIC_* variables are read but in production (build) the VITE_* variables are read instead. BIzqDs9Lpj.mp4 |
oh wait, you're using custom sw, maybe we need to change the astro pwa integration... We'll need to include |
tree shaking also working... nice |
@Eptagone released 0.3.1 version, this issue should be fixed (your reproduction working) |
I can confirm that it's working now. Thank very much! |
If you have client environment variables which should be included in the client side scripts, in Astro projects, they should have the prefix
PUBLIC_
but if you want to include them in a custom service worker, it won't work because VitePWA is ignoring them.That's because VitePWA is expecting variables with the prefix
VITE_
.The default value for the environment prefix in Vite is VITE_ but in Astro that prefix is PUBLIC_ instead.
The text was updated successfully, but these errors were encountered: