Skip to content

Commit dd8f2b1

Browse files
branchseerclaude
andcommitted
fix(static-config): match Vite's DEFAULT_CONFIG_FILES resolution order
The config file resolution order was .ts first, but Vite resolves .js, .mjs, .ts, .cjs, .mts, .cts — matching that order now. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6a23db4 commit dd8f2b1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • crates/vite_static_config/src

crates/vite_static_config/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ use rustc_hash::FxHashMap;
1616
use vite_path::AbsolutePath;
1717

1818
/// Config file names to try, in priority order.
19+
/// This matches Vite's `DEFAULT_CONFIG_FILES` order.
1920
const CONFIG_FILE_NAMES: &[&str] = &[
20-
"vite.config.ts",
2121
"vite.config.js",
22-
"vite.config.mts",
2322
"vite.config.mjs",
24-
"vite.config.cts",
23+
"vite.config.ts",
2524
"vite.config.cjs",
25+
"vite.config.mts",
26+
"vite.config.cts",
2627
];
2728

2829
/// Resolve the vite config file path in the given directory.
@@ -349,16 +350,16 @@ mod tests {
349350
}
350351

351352
#[test]
352-
fn ts_takes_priority_over_js() {
353+
fn js_takes_priority_over_ts() {
353354
let dir = TempDir::new().unwrap();
354355
let dir_path = vite_path::AbsolutePathBuf::new(dir.path().to_path_buf()).unwrap();
355356
std::fs::write(dir.path().join("vite.config.ts"), "export default { fromTs: true }")
356357
.unwrap();
357358
std::fs::write(dir.path().join("vite.config.js"), "export default { fromJs: true }")
358359
.unwrap();
359360
let result = resolve_static_config(&dir_path);
360-
assert!(result.contains_key("fromTs"));
361-
assert!(!result.contains_key("fromJs"));
361+
assert!(result.contains_key("fromJs"));
362+
assert!(!result.contains_key("fromTs"));
362363
}
363364

364365
#[test]

0 commit comments

Comments
 (0)