@@ -56,13 +56,16 @@ function resolvePath(path: string, root: string) {
5656 )
5757}
5858
59- export function findConfigFile ( root : string ) : string | undefined {
59+ export function findConfigFile ( root : string ) : string | false {
6060 for ( const configFile of configFiles ) {
6161 const configPath = resolve ( root , configFile )
6262 if ( existsSync ( configPath ) ) {
6363 return configPath
6464 }
6565 }
66+ // if not found, then there is no config to find.
67+ // `false` will stop vite from trying to find it again
68+ return false
6669}
6770
6871function parseInspector ( inspect : string | undefined | boolean | number ) {
@@ -1118,10 +1121,12 @@ export async function resolveConfig(
11181121 // We clone CLI Options and Vite overrides to reuse when a watch mode is triggered.
11191122 const cliOptionsCopy = deepMerge ( { } , options ) as UserConfig
11201123 const viteOverridesCopy = deepMerge ( { } , viteOverrides ) as ViteUserConfig
1121- const root = resolve ( options . root || process . cwd ( ) )
1122- const configPath = resolveConfigPath ( root , options )
1124+ const configPath = resolveConfigPath (
1125+ // try to find the config relative to `--root` or process.cwd()
1126+ resolve ( options . root || process . cwd ( ) ) ,
1127+ options ,
1128+ )
11231129 options . config = configPath
1124- options . root = root
11251130
11261131 const captures : ConfigResolutionCaptures = { }
11271132 const inlineConfig : InlineConfig = mergeConfig (
@@ -1135,11 +1140,11 @@ export async function resolveConfig(
11351140 CaptureRawTestConfig ( captures , cliOptionsCopy . sharedViteServer ) ,
11361141 ...TestConfigPlugin ( pluginsHarness , captures , cliOptionsCopy ) ,
11371142 ...ViteConfigPlugin ( pluginsHarness ) ,
1138- ...VitestCorePlugin ( pluginsHarness , options ) ,
1143+ ...VitestCorePlugin ( pluginsHarness ) ,
11391144 ...BrowserLoaderPlugin ( captures , pluginsHarness ) ,
11401145 ] ,
11411146 } satisfies InlineConfig ,
1142- mergeConfig ( viteOverrides , { root } ) ,
1147+ viteOverrides ,
11431148 )
11441149
11451150 const rootViteConfig = await viteResolveConfig ( inlineConfig , 'serve' )
0 commit comments