From a51c254265bbfe3d77f834fe81a503ce27c05b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 6 Nov 2024 15:11:24 +0900 Subject: [PATCH] chore: add warning for `/` mapping in `resolve.alias` (#18588) Co-authored-by: Bjorn Lu --- packages/vite/src/node/config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index fbfda1452de235..a536058e8e1789 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -806,6 +806,16 @@ function resolveResolveOptions( // resolve alias with internal client alias const alias = normalizeAlias(mergeAlias(clientAlias, resolve?.alias || [])) const preserveSymlinks = resolve?.preserveSymlinks ?? false + + if (alias.some((a) => a.find === '/')) { + logger.warn( + colors.yellow( + `\`resolve.alias\` contains an alias that maps \`/\`. ` + + `This is not recommended as it can cause unexpected behavior when resolving paths.`, + ), + ) + } + return resolveEnvironmentResolveOptions( resolve, alias,