Skip to content

fix: add deprecation warning for config.envFile#22569

Closed
godfengliang wants to merge 1 commit into
vitejs:mainfrom
godfengliang:fix-envfile-deprecation-warning
Closed

fix: add deprecation warning for config.envFile#22569
godfengliang wants to merge 1 commit into
vitejs:mainfrom
godfengliang:fix-envfile-deprecation-warning

Conversation

@godfengliang

Copy link
Copy Markdown

Description

Fixes #22547

InlineConfig.envFile is marked as @deprecated in the TypeScript definition, but no runtime deprecation warning is emitted when it is used. This means users calling the programmatic API with { envFile: false } receive no guidance to migrate to { envDir: false }.

What This PR Does

Adds a logger.warn() call in packages/vite/src/node/config.ts (L1678-1683) that emits a deprecation warning when config.envFile === false is used:

config.envFile is deprecated. Use config.envDir instead. For example, replace { envFile: false } with { envDir: false }.

This follows the existing pattern used by other deprecation/warning messages in the same file (e.g., L1696, L1497).

How to Test

  1. Create a Vite config with { envFile: false }
  2. Run Vite dev server or build
  3. Observe the deprecation warning in the console output

Before this fix: No warning is emitted.
After this fix: A clear migration guide is shown to the user.

Fixes vitejs#22547

`config.envFile` is marked as `@deprecated` in the TypeScript definition
but no runtime warning was emitted when users used it. This adds a
`logger.warn()` call to guide users to migrate to `config.envDir`.
Comment on lines +1679 to +1682
logger.warn(
'config.envFile is deprecated. Use config.envDir instead. ' +
'For example, replace { envFile: false } with { envDir: false }.',
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use colors.yellow, and we can also shorten this following the other warning patterns:

Suggested change
logger.warn(
'config.envFile is deprecated. Use config.envDir instead. ' +
'For example, replace { envFile: false } with { envDir: false }.',
)
logger.warn(
colors.yellow(
'The `envFile` option is deprecated, please use `envDir: false` instead. ',
),
)

Might need to be formatted

@sapphi-red

Copy link
Copy Markdown
Member

closing as it seems #22555 was merged

@sapphi-red sapphi-red closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InlineConfig.envFile is deprecated but no runtime warning is emitted

3 participants