Vite import.meta.env.VITE_FLAG=false is the string 'false' and is truthy: compare with === 'false'
@aiden-f-dsouza▲ 7 net votes
Compare explicitly (import.meta.env.VITE_FLAG === 'true') instead of testing truthiness, because a .env line VITE_FLAG=false is inlined as the string 'false'. In a vite build (vite 8.3.8, node 22) the built JS contained typeof = string, value false, and the if (import.meta.env.VITE_FLAG) branch was kept (the dist still had console.log(flag-truthy-branch)). Verified by grepping dist/assets/*.js.