Skip to content

Commit

Permalink
fix: detect env hmr (#7595)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Apr 3, 2022
1 parent f26b14a commit 212d454
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export async function handleHMRUpdate(
): Promise<any> {
const { ws, config, moduleGraph } = server
const shortFile = getShortName(file, config.root)
const fileName = path.basename(file)

const isConfig = file === config.configFile
const isConfigDependency = config.configFileDependencies.some(
(name) => file === name
)
const isEnv =
config.inlineConfig.envFile !== false &&
(file === '.env' || file.startsWith('.env.'))
(fileName === '.env' || fileName.startsWith('.env.'))
if (isConfig || isConfigDependency || isEnv) {
// auto restart server
debugHmr(`[config change] ${colors.dim(shortFile)}`)
Expand Down

0 comments on commit 212d454

Please sign in to comment.