Could you try to set the variables in Netlify UI to make sure it’s not a problem of .env file being read/ignored?
Additionally, if that still doesn’t work, just to go to a primitive stage to debug, try setting a static value for the variables like VITE_COMMIT_REF=1 and see if you can get that value to work.
Yes that works. I have a VITE_ENVIRONMENT variable being set through the UI and it works fine. I want dynamic ones like commit ref or review id though so I need it to work through the .env file as well.
Commit ref should be injected by Netlify into the .env file then should be displayed. It doesn’t work.
Netlify UI variable is injected by the Netlify UI straight into the app.
Not Netlify is a hardcoded variable in the .env file to prove the .env file is working.
This took some time, but you can do it by changing your build command to VITE_COMMIT_REF=$COMMIT_REF npm run build. Then you won’t need to set the variable anywhere else. Example: https://compassionate-bassi-1f663e.netlify.app