Hey guys, I have bumped into a problem with runtime variables in the Kubernetes infrastructure. I would like to have the same build (Docker image) but run it with different set of variables WITHOUT .env file. The Kubernetes manages to inject those.
It all works with
vite: {
define: {
'import.meta.env.MY_RUNTIME_VARIABLE': 'process.env.MY_RUNTIME_VARIABLE',
...
},
}
So all in-app (.astro and the .js|ts files imported to astro files) are successfully runtime.
But...,
It does not work with the configuration files!
As official docs says, the configuration files are first even before other files being loaded https://docs.astro.build/en/guides/configuring-astro/#environment-variables, so VITE does not exist there yet.
Is there any way to make different configuration in a same build. Basically I need to achieve, that dist js files would have process.env.* instead of actual secret hardcoded during build time.. And I would like to avoid making 2 builds for different purposes.