I recently deployed a new Vite
image from my dev envrionment to my prod envrionment
and noticed that the client didn’t work because it was still using the envrionment variables from dev
, even when changing the configmap.
From there I realized that Vite
(and generally other client bundlers) build statically, meaning the envs are replaced on build which means I can’t inject them dynamically with a configmap.
That’s a problem because I have multiple envrionments I need my Image to support and I can’t go and “break” the Image for one envrionment to make it work on another.
I tried doing a trick using window.env
which a team member of mine used on our old webpack
images but I couldn’t get it to work.
Is there a way to configure Vite to build dynamically? Or maybe there is a trick using window.evn
for Vite
and I just didn’t manage to implement it correctly.
Thanks