Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
isFilePathESM,
isNodeBuiltin,
isObject,
isParentDirectory,
mergeAlias,
mergeConfig,
normalizeAlias,
Expand Down Expand Up @@ -914,6 +915,20 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
)
}

const resolvedBuildOutDir = normalizePath(
path.resolve(resolved.root, resolved.build.outDir),
)
if (
isParentDirectory(resolvedBuildOutDir, resolved.root) ||
resolvedBuildOutDir === resolved.root
) {
resolved.logger.warn(
colors.yellow(`
(!) build.outDir must not be the same directory of root or a parent directory of root as this could cause Vite to overwriting source files with build outputs.
`),
)
}

return resolved
}

Expand Down