From d0f1d2e5fee1e923b89289c48fde79636afb1dc0 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Tue, 16 Jan 2024 13:45:03 +0800 Subject: [PATCH] fix(hmr): normalize env files path (#15584) --- packages/vite/src/node/env.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/env.ts b/packages/vite/src/node/env.ts index 481a50db63f105..1052f894ec8c2d 100644 --- a/packages/vite/src/node/env.ts +++ b/packages/vite/src/node/env.ts @@ -2,7 +2,7 @@ import fs from 'node:fs' import path from 'node:path' import { parse } from 'dotenv' import { expand } from 'dotenv-expand' -import { arraify, tryStatSync } from './utils' +import { arraify, normalizePath, tryStatSync } from './utils' import type { UserConfig } from './config' export function getEnvFilesForMode(mode: string, envDir: string): string[] { @@ -11,7 +11,7 @@ export function getEnvFilesForMode(mode: string, envDir: string): string[] { /** local file */ `.env.local`, /** mode file */ `.env.${mode}`, /** mode local file */ `.env.${mode}.local`, - ].map((file) => path.join(envDir, file)) + ].map((file) => normalizePath(path.join(envDir, file))) } export function loadEnv(