File tree Expand file tree Collapse file tree
packages/start/src/server/manifest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ function createHtmlTagsForAssets(assets: string[]) {
6666 } ) ) ;
6767}
6868
69+ const entryId = import . meta. env . START_CLIENT_ENTRY . slice ( 2 ) ;
70+ let entryImports : string [ ] | undefined = undefined ;
71+
6972function findAssetsInViteManifest (
7073 manifest : any ,
7174 id : string ,
@@ -85,17 +88,30 @@ function findAssetsInViteManifest(
8588 return [ ] ;
8689 }
8790
91+ if ( ! entryImports ) {
92+ entryImports = [
93+ entryId ,
94+ ...( manifest [ entryId ] ?. imports ?? [ ] )
95+ ] ;
96+ }
97+
98+ // Only include entry imports, if we are specifically crawling the entry
99+ // Chunks (e.g. routes) that import something from entry, should not render entry css redundantly
100+ const excludeEntryImports = id !== entryId ;
101+
88102 const assets = [
89103 ...( chunk . assets ?. filter ( Boolean ) || [ ] ) ,
90104 ...( chunk . css ?. filter ( Boolean ) || [ ] ) ,
91105 ] ;
92106 if ( chunk . imports ) {
93107 stack . push ( id ) ;
94108 for ( let i = 0 , l = chunk . imports . length ; i < l ; i ++ ) {
109+ const importId = chunk . imports [ i ] ;
110+ if ( ! importId || ( excludeEntryImports && entryImports . includes ( importId ) ) ) continue ;
95111 assets . push (
96112 ...findAssetsInViteManifest (
97113 manifest ,
98- chunk . imports [ i ] ,
114+ importId ,
99115 assetMap ,
100116 stack ,
101117 ) ,
You can’t perform that action at this time.
0 commit comments