-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Labels
Description
Describe the bug
I'm running webpack 5
inside the web container, and passed in environment variable MYFLAG
. The source code uses process.env.MYFLAG
to read the environment variable. In webpack.config.js
, I can correctly read the MYFLAG value. But in src/index.js
, process.env.MYFLAG
is sometimes undefined
, and sometimes the correct value. The result of process.env.MYFLAG
in the bundled code is unpredictable. I tried to read pre-defined variables like process.env.HOME
, the result is the same.
Link to the blitz that caused the error
https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-fapmje?file=files.js
Steps to reproduce
- Go to the stackblitz link
- See the preview window and console log.
- During running
webpack
, MYFLAG is correctly printed to console log. - The preview window on the right shows: "flag: undefined", which should be "flag: PASSED_IN_FLAG"
- Rerun this at different times, the preview window can sometimes show the expected result.
Expected behavior
webpack should read process.env
reliably for bundled code
Parity with Local
- I have run the project in my local machine and I could not reproduce the issue.
Screenshots
No response
Platform
No response
Additional context
No response