Skip to content
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

Runtime environment #207

Merged
merged 4 commits into from
May 25, 2024
Merged

Runtime environment #207

merged 4 commits into from
May 25, 2024

Conversation

davenquinn
Copy link
Member

@davenquinn davenquinn commented May 25, 2024

This PR allows us to avoid re-bundling the app to integrate environment variables in production.

We take all VITE_-prefixed environment variables provided on the server and package them in a dictionary that is provided as both process.env (server-side) and window.env (client-side).

These variables can then be accessed using a getRuntimeConfig function in either environment. Right now, that falls back to existing pre-bundled environment variables if they aren't provided at runtime, but we may want to change this behavior for clarity in the future.

This approach requires some amount of discipline to not use environment variables directly in client-side code, but allows us to remove all bundling of the app in production, saving quite a bit of time on app startup.

@davenquinn davenquinn requested a review from CannonLock May 25, 2024 06:04
@davenquinn davenquinn merged commit 920c4cf into main May 25, 2024
2 checks passed
@davenquinn davenquinn deleted the runtime-environment branch May 25, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant