Use environment variable in defineConfig
I have an
.env.local
file
Before SolidStart 0.4, to define the proxy to this API host, I defined in vite.config.js
like so
Starting from SolidStart 0.4, the callback is no longer used. I tried the following
But the server can not recognize the process.env.VITE_API_HOST
. How can I use environment variables in this case?3 Replies
Since the env file is not automatically parsed into process.env, you need to do it manually. Unfortunately, defineConfig from start does not have a function argument with the mode. I currently have no idea how to solve this.
For now, I use
loadEnv
Sure, but you cannot use the mode.
If that doesn't bother you, that's fine, but I think we should have a better solution in the future.