@@ -68,6 +68,10 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
6868 let rootDir : string | null = null ;
6969
7070 let ssrOutDir : string | null = null ;
71+ // Cache the user-specified clientOutDir to use across multiple normalizeOptions calls
72+ const userClientOutDir = qwikViteOpts . client ?. outDir ;
73+ // Cache the resolved plugin options from config() to reuse in configResolved()
74+ let cachedPluginOpts : QwikPluginOptions | null = null ;
7175 const fileFilter : QwikVitePluginOptions [ 'fileFilter' ] = qwikViteOpts . fileFilter
7276 ? ( id , type ) => TRANSFORM_REGEX . test ( id ) || qwikViteOpts . fileFilter ! ( id , type )
7377 : ( ) => true ;
@@ -168,9 +172,10 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
168172 outDir : viteConfig . build ?. outDir ,
169173 ssrOutDir : qwikViteOpts . ssr ?. outDir || viteConfig . build ?. outDir ,
170174 clientOutDir :
171- qwikViteOpts . client ?. outDir ||
175+ userClientOutDir ||
172176 // When ssr is true, this is probably an adapter build and not where the client build is
173- ( viteConfig . build ?. ssr ? undefined : viteConfig . build ?. outDir ) ,
177+ // However, if client.outDir was explicitly set, always use it
178+ ( viteConfig . build ?. ssr && ! userClientOutDir ? undefined : viteConfig . build ?. outDir ) ,
174179 assetsDir : useAssetsDir ? viteAssetsDir : undefined ,
175180 devTools : qwikViteOpts . devTools ,
176181 sourcemap : ! ! viteConfig . build ?. sourcemap ,
@@ -185,6 +190,9 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
185190 const opts = await qwikPlugin . normalizeOptions ( pluginOpts ) ;
186191 input ||= opts . input ;
187192
193+ // Cache pluginOpts for use in configResolved()
194+ cachedPluginOpts = pluginOpts ;
195+
188196 manifestInput = opts . manifestInput ;
189197 srcDir = opts . srcDir ;
190198 rootDir = opts . rootDir ;
@@ -358,7 +366,12 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
358366 qwikPlugin . setSourceMapSupport ( true ) ;
359367 }
360368 // Ensure that the final settings are applied
361- qwikPlugin . normalizeOptions ( qwikViteOpts ) ;
369+ // Use cachedPluginOpts if available to preserve clientOutDir
370+ if ( cachedPluginOpts ) {
371+ qwikPlugin . normalizeOptions ( cachedPluginOpts ) ;
372+ } else {
373+ qwikPlugin . normalizeOptions ( qwikViteOpts ) ;
374+ }
362375 } ,
363376
364377 async buildStart ( ) {
0 commit comments