@@ -258,6 +258,12 @@ async function createInternalBuildConfig(
258258 } ,
259259 } ,
260260 source : {
261+ preEntry : [
262+ // ensure CSS orders and access @theme before @rspress/theme-default to avoid circular dependency
263+ path . join ( DEFAULT_THEME , './styles/index.js' ) , // 1. @rspress/theme-default global styles
264+ 'virtual-global-styles' , // 2. virtual-global-styles
265+ '@theme' , // 3. import './index.css'; from 'theme/index.tsx'
266+ ] ,
261267 include : [ PACKAGE_ROOT ] ,
262268 define : {
263269 'process.env.TEST' : JSON . stringify ( process . env . TEST ) ,
@@ -369,20 +375,20 @@ async function createInternalBuildConfig(
369375 . test ( / \. r s p r e s s [ \\ / ] r u n t i m e [ \\ / ] v i r t u a l - g l o b a l - s t y l e s / )
370376 . merge ( { sideEffects : true } ) ;
371377
378+ if ( isSsg || isSsgMd ) {
379+ chain . optimization . splitChunks ( { } ) ;
380+ }
381+
372382 if ( isSsg ) {
373383 chain . output . filename (
374384 `${ NODE_SSG_BUNDLE_FOLDER } /${ NODE_SSG_BUNDLE_NAME } ` ,
375385 ) ;
376386 chain . output . chunkFilename ( `${ NODE_SSG_BUNDLE_FOLDER } /[name].cjs` ) ;
377- // For perf
378- chain . output . set ( 'asyncChunks' , false ) ;
379387 } else if ( isSsgMd ) {
380388 chain . output . filename (
381389 `${ NODE_SSG_MD_BUNDLE_FOLDER } /${ NODE_SSG_MD_BUNDLE_NAME } ` ,
382390 ) ;
383391 chain . output . chunkFilename ( `${ NODE_SSG_MD_BUNDLE_FOLDER } /[name].cjs` ) ;
384- // For perf
385- chain . output . set ( 'asyncChunks' , false ) ;
386392 }
387393 } ,
388394 } ,
@@ -399,10 +405,6 @@ async function createInternalBuildConfig(
399405 index :
400406 enableSSG && isProduction ( ) ? SSR_CLIENT_ENTRY : CSR_CLIENT_ENTRY ,
401407 } ,
402- preEntry : [
403- path . join ( DEFAULT_THEME , './styles/index.js' ) ,
404- 'virtual-global-styles' ,
405- ] ,
406408 define : {
407409 'process.env.__SSR__' : JSON . stringify ( false ) ,
408410 'process.env.__SSR_MD__' : JSON . stringify ( false ) ,
0 commit comments