@@ -39,9 +39,11 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
3939 * NOTE: we don't perform critical CSS inlining as this will be done during server rendering.
4040 */
4141 let indexContentOutputNoCssInlining ;
42+ // When using prerender/app-shell the index HTML file can be regenerated.
43+ // Thus, we use a Map so that we do not generate 2 files with the same filename.
44+ const additionalHtmlOutputFiles = new Map ( ) ;
4245 // Generate index HTML file
4346 // If localization is enabled, index generation is handled in the inlining process.
44- // NOTE: Localization with SSR is not currently supported.
4547 if ( indexHtmlOptions ) {
4648 const { content, contentWithoutCriticalCssInlined, errors, warnings } = await ( 0 , index_html_generator_1 . generateIndexHtml ) ( initialFiles , outputFiles , {
4749 ...options ,
@@ -50,9 +52,10 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
5052 indexContentOutputNoCssInlining = contentWithoutCriticalCssInlined ;
5153 allErrors . push ( ...errors ) ;
5254 allWarnings . push ( ...warnings ) ;
53- additionalOutputFiles . push ( ( 0 , utils_1 . createOutputFileFromText ) ( indexHtmlOptions . output , content , bundler_context_1 . BuildOutputFileType . Browser ) ) ;
55+ additionalHtmlOutputFiles . set ( indexHtmlOptions . output , ( 0 , utils_1 . createOutputFileFromText ) ( indexHtmlOptions . output , content , bundler_context_1 . BuildOutputFileType . Browser ) ) ;
5456 if ( ssrOptions ) {
55- additionalOutputFiles . push ( ( 0 , utils_1 . createOutputFileFromText ) ( 'index.server.html' , contentWithoutCriticalCssInlined , bundler_context_1 . BuildOutputFileType . Server ) ) ;
57+ const serverIndexHtmlFilename = 'index.server.html' ;
58+ additionalHtmlOutputFiles . set ( serverIndexHtmlFilename , ( 0 , utils_1 . createOutputFileFromText ) ( serverIndexHtmlFilename , contentWithoutCriticalCssInlined , bundler_context_1 . BuildOutputFileType . Server ) ) ;
5659 }
5760 }
5861 // Pre-render (SSG) and App-shell
@@ -64,9 +67,10 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
6467 allWarnings . push ( ...warnings ) ;
6568 prerenderedRoutes . push ( ...Array . from ( generatedRoutes ) ) ;
6669 for ( const [ path , content ] of Object . entries ( output ) ) {
67- additionalOutputFiles . push ( ( 0 , utils_1 . createOutputFileFromText ) ( path , content , bundler_context_1 . BuildOutputFileType . Browser ) ) ;
70+ additionalHtmlOutputFiles . set ( path , ( 0 , utils_1 . createOutputFileFromText ) ( path , content , bundler_context_1 . BuildOutputFileType . Browser ) ) ;
6871 }
6972 }
73+ additionalOutputFiles . push ( ...additionalHtmlOutputFiles . values ( ) ) ;
7074 // Augment the application with service worker support
7175 // If localization is enabled, service worker is handled in the inlining process.
7276 if ( serviceWorker ) {
0 commit comments