diff --git a/.changeset/windows-root-case.md b/.changeset/windows-root-case.md new file mode 100644 index 000000000000..d346dd5eab0d --- /dev/null +++ b/.changeset/windows-root-case.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: avoid Vite override warnings for Windows path case differences diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index 1ab5f669759c..0ef77ac00970 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -1640,6 +1640,30 @@ function warn_overridden_config(config, resolved_config) { } } +const case_insensitive_path_keys = new Set([ + 'root', + 'publicDir', + 'build.outDir', + 'build.lib.entry', + 'build.rollupOptions.input' +]); + +/** + * @param {any} value + * @param {string} keypath + */ +function normalize_config_value(value, keypath) { + if (typeof value !== 'string') { + return value; + } + + const normalized = posixify(value); + const is_path_config = + case_insensitive_path_keys.has(keypath) || keypath.startsWith('resolve.alias.'); + + return process.platform === 'win32' && is_path_config ? normalized.toLowerCase() : normalized; +} + /** * @param {Record} config * @param {Record} resolved_config @@ -1660,8 +1684,8 @@ function find_overridden_config(config, resolved_config, enforced_config, path, if (enforced === true) { // Normalize path separators before comparing to avoid false positives on Windows, // where config values like `root` may use backslashes while SvelteKit uses forward slashes. - const a = typeof config[key] === 'string' ? posixify(config[key]) : config[key]; - const b = typeof resolved === 'string' ? posixify(resolved) : resolved; + const a = normalize_config_value(config[key], path + key); + const b = normalize_config_value(resolved, path + key); if (a !== b) { out.push(path + key); }