@@ -1064,23 +1064,17 @@ export async function readSourcesFromFilesystem() {
10641064`
10651065 }
10661066
1067- // Skip virtual templates when prerendering - sources are written to filesystem instead
1068- // In dev mode, always generate sources even if prerenderSitemap is true (e.g. zeroRuntime)
1069- if ( prerenderSitemap && ! nuxt . options . dev ) {
1070- nitroConfig . virtual [ '#sitemap-virtual/global-sources.mjs' ] = `export const sources = []`
1071- nitroConfig . virtual [ `#sitemap-virtual/child-sources.mjs` ] = `export const sources = {}`
1067+ // Virtual templates provide the initial build-time sources. During
1068+ // prerender, the filesystem handoff replaces them with the final sources
1069+ // after all routes have been crawled.
1070+ nitroConfig . virtual [ '#sitemap-virtual/global-sources.mjs' ] = async ( ) => {
1071+ const globalSources = await generateGlobalSources ( )
1072+ return `export const sources = ${ JSON . stringify ( globalSources , null , 4 ) } `
10721073 }
1073- else {
1074- // Virtual templates generate sources data - will be cached in storage on first use
1075- nitroConfig . virtual [ '#sitemap-virtual/global-sources.mjs' ] = async ( ) => {
1076- const globalSources = await generateGlobalSources ( )
1077- return `export const sources = ${ JSON . stringify ( globalSources , null , 4 ) } `
1078- }
10791074
1080- nitroConfig . virtual ! [ `#sitemap-virtual/child-sources.mjs` ] = async ( ) => {
1081- const childSources = await generateChildSources ( )
1082- return `export const sources = ${ JSON . stringify ( childSources , null , 4 ) } `
1083- }
1075+ nitroConfig . virtual ! [ `#sitemap-virtual/child-sources.mjs` ] = async ( ) => {
1076+ const childSources = await generateChildSources ( )
1077+ return `export const sources = ${ JSON . stringify ( childSources , null , 4 ) } `
10841078 }
10851079 } )
10861080
0 commit comments