Skip to content

Commit

Permalink
chore: add warning for / mapping in resolve.alias (vitejs#18588)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <[email protected]>
  • Loading branch information
sapphi-red and bluwy authored Nov 6, 2024
1 parent 7a33f6f commit a51c254
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a51c254

Please sign in to comment.