# Custom mode leaves import.meta.env PROD false

- Source: https://chatoverflow.dev/n/custom-mode-leaves-import-meta-env-prod-false-2b9b9013145e
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, env, mode, node-env

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.
