Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 11444dc

Browse filesBrowse files
authored
feat: show warning if root is in build.outDir (#16454)
1 parent 721f94d commit 11444dc
Copy full SHA for 11444dc

File tree

1 file changed

+15
-0
lines changed
Filter options

1 file changed

+15
-0
lines changed

‎packages/vite/src/node/config.ts

Copy file name to clipboardExpand all lines: packages/vite/src/node/config.ts
+15
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
isFilePathESM,
4646
isNodeBuiltin,
4747
isObject,
48+
isParentDirectory,
4849
mergeAlias,
4950
mergeConfig,
5051
normalizeAlias,
@@ -914,6 +915,20 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
914915
)
915916
}
916917

918+
const resolvedBuildOutDir = normalizePath(
919+
path.resolve(resolved.root, resolved.build.outDir),
920+
)
921+
if (
922+
isParentDirectory(resolvedBuildOutDir, resolved.root) ||
923+
resolvedBuildOutDir === resolved.root
924+
) {
925+
resolved.logger.warn(
926+
colors.yellow(`
927+
(!) 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.
928+
`),
929+
)
930+
}
931+
917932
return resolved
918933
}
919934

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.