Open jrmdayn opened 2 years ago
Hi, how exactly are you using env variables in main? I have a feeling there might be an issue with env variable destructuring
In the main I look through process.env
for variables.
I looked at the output of build --verbose
and I do see the variables from my .env
files being passed through the define
prop to esbuild
.
After further investigation, I realized that my logic for getting an env variable from the main was actually located under another folder shared/
where I call process.env
etc.. If I log the content of process.env
from a file within shared/
I do not see the variables coming from my dotenv files. But when I do this from a file in the main/
folder they are there...
I can work around this short term but it would be nice to understand what's going on..
Yeah, if you don't use the variables directly, but rather dynamically or via destructuring it won't work (https://github.com/evanw/esbuild/issues/438#issuecomment-857500937). I might look later around for newer techniques to handle this better.
ok thanks for the pointers. That's a shame that esbuild does not handle this correctly out of the box 😢
Hey 👋 ! Great work, thank you for this project!
I noticed that .env files are correctly read in dev mode in the main, but not in production (using
yarn try
for ex). Any idea on how I could make this work?Thanks a lot 🙏