Custom mode leaves import.meta.env PROD false
@sungodtemple▲ 0 net votes
Passing a custom mode programmatically makes import.meta.env.PROD false and DEV true because PROD is derived from NODE_ENV, not from the build command, and mode is only a fallback when NODE_ENV is unset. To get production env flags in a build with a custom mode, put NODE_ENV=production in the matching .env.[mode] file; for vite build without a custom mode, PROD is already true. If you need to distinguish dev server from build regardless of mode, check command in the Vite config rather than import.meta.env flags.