I'm having a hard time configuring the frontend apps (frontend, admin, presenter) at runtime. Vite/Vike will replace all occurences of import.meta.env at build time. There is no documented way to configure these apps after npm run build has happened.
This basically makes it impossible to follow both config + build/run principles of the 12 factors. Either we include the development dependencies and the build step in the docker images, leading to huge image sizes, long start up times and higher memory consumption on the target environment. Or we build docker images specifically for each deployment with pre-configured values, which means a lot of docker images and long development cycles when you want to change configuration.
To me, I don't quite get it why Vike does not implement runtime environment variables if it handles SSR. I understand that you will run into this problem with prerender: true. But if we have a nodejs runtime and it's doing SSR, why it is not able to replace environment variables as well?
Edit: As of now, our docker images for frontend and presenter have baked in .env.production files. When we find a solution for this problem, these two files have to go away. Their presence leads to misconfiguration on the vServer which pulls from the upstream git repository during deployment.
💥 DevOps
I'm having a hard time configuring the frontend apps (frontend, admin, presenter) at runtime. Vite/Vike will replace all occurences of
import.meta.env
at build time. There is no documented way to configure these apps afternpm run build
has happened.This basically makes it impossible to follow both config + build/run principles of the 12 factors. Either we include the development dependencies and the build step in the docker images, leading to huge image sizes, long start up times and higher memory consumption on the target environment. Or we build docker images specifically for each deployment with pre-configured values, which means a lot of docker images and long development cycles when you want to change configuration.
To me, I don't quite get it why Vike does not implement runtime environment variables if it handles SSR. I understand that you will run into this problem with
prerender: true
. But if we have a nodejs runtime and it's doing SSR, why it is not able to replace environment variables as well?See: https://github.com/vikejs/vike/issues/1726
Here are some hacks addressing this problem for Vite: https://github.com/runtime-env/import-meta-env https://github.com/geprog/vite-plugin-env-config https://github.com/micha149/vite-plugin-runtime-env
Edit: As of now, our docker images for
frontend
andpresenter
have baked in.env.production
files. When we find a solution for this problem, these two files have to go away. Their presence leads to misconfiguration on the vServer which pulls from the upstream git repository during deployment.