@@ -309,6 +309,14 @@ export default function vitePluginRsc(
309309 {
310310 name : 'rsc' ,
311311 async config ( config , env ) {
312+ if ( config . rsc ) {
313+ // mutate `rscPluginOptions` since internally this object is passed around
314+ Object . assign (
315+ rscPluginOptions ,
316+ // not sure which should win. for now plugin constructor wins.
317+ vite . mergeConfig ( config . rsc , rscPluginOptions ) ,
318+ )
319+ }
312320 // crawl packages with "react" in "peerDependencies" to bundle react deps on server
313321 // see https://github.com/svitejs/vitefu/blob/d8d82fa121e3b2215ba437107093c77bde51b63b/src/index.js#L95-L101
314322 const result = await crawlFrameworkPkgs ( {
@@ -332,7 +340,7 @@ export default function vitePluginRsc(
332340 ]
333341
334342 return {
335- appType : 'custom' ,
343+ appType : config . appType ?? 'custom' ,
336344 define : {
337345 'import.meta.env.__vite_rsc_build__' : JSON . stringify (
338346 env . command === 'build' ,
@@ -412,11 +420,21 @@ export default function vitePluginRsc(
412420 builder : {
413421 sharedPlugins : true ,
414422 sharedConfigBuild : true ,
415- buildApp : rscPluginOptions . useBuildAppHook ? undefined : buildApp ,
423+ async buildApp ( builder ) {
424+ if ( ! rscPluginOptions . useBuildAppHook ) {
425+ await buildApp ( builder )
426+ }
427+ } ,
416428 } ,
417429 }
418430 } ,
419- buildApp : rscPluginOptions . useBuildAppHook ? buildApp : undefined ,
431+ buildApp : {
432+ async handler ( builder ) {
433+ if ( rscPluginOptions . useBuildAppHook ) {
434+ await buildApp ( builder )
435+ }
436+ } ,
437+ } ,
420438 configureServer ( server ) {
421439 ; ( globalThis as any ) . __viteRscDevServer = server
422440
@@ -989,6 +1007,7 @@ import.meta.hot.on("rsc:update", () => {
9891007 ...vitePluginRscMinimal ( rscPluginOptions , manager ) ,
9901008 ...vitePluginFindSourceMapURL ( ) ,
9911009 ...vitePluginRscCss ( rscPluginOptions , manager ) ,
1010+ // TODO: delay validateImports option check after config
9921011 ...( rscPluginOptions . validateImports !== false
9931012 ? [ validateImportPlugin ( ) ]
9941013 : [ ] ) ,
0 commit comments