mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 13:32:43 +08:00
fix(@angular-devkit/build-angular): app-shell generation incorrect content when using the application builder
In some cases, the index.html file emitted contained the wrong contents. This because in OutputFiles there were present multiple files with the same name. Closes #26593
This commit is contained in:
parent
b5b0432913
commit
e3ad8c42a7
@ -66,9 +66,12 @@ export async function executePostBundleSteps(
|
||||
*/
|
||||
let indexContentOutputNoCssInlining: string | undefined;
|
||||
|
||||
// When using prerender/app-shell the index HTML file can be regenerated.
|
||||
// Thus, we use a Map so that we do not generate 2 files with the same filename.
|
||||
const additionalHtmlOutputFiles = new Map<string, BuildOutputFile>();
|
||||
|
||||
// Generate index HTML file
|
||||
// If localization is enabled, index generation is handled in the inlining process.
|
||||
// NOTE: Localization with SSR is not currently supported.
|
||||
if (indexHtmlOptions) {
|
||||
const { content, contentWithoutCriticalCssInlined, errors, warnings } = await generateIndexHtml(
|
||||
initialFiles,
|
||||
@ -84,14 +87,17 @@ export async function executePostBundleSteps(
|
||||
allErrors.push(...errors);
|
||||
allWarnings.push(...warnings);
|
||||
|
||||
additionalOutputFiles.push(
|
||||
additionalHtmlOutputFiles.set(
|
||||
indexHtmlOptions.output,
|
||||
createOutputFileFromText(indexHtmlOptions.output, content, BuildOutputFileType.Browser),
|
||||
);
|
||||
|
||||
if (ssrOptions) {
|
||||
additionalOutputFiles.push(
|
||||
const serverIndexHtmlFilename = 'index.server.html';
|
||||
additionalHtmlOutputFiles.set(
|
||||
serverIndexHtmlFilename,
|
||||
createOutputFileFromText(
|
||||
'index.server.html',
|
||||
serverIndexHtmlFilename,
|
||||
contentWithoutCriticalCssInlined,
|
||||
BuildOutputFileType.Server,
|
||||
),
|
||||
@ -130,12 +136,15 @@ export async function executePostBundleSteps(
|
||||
prerenderedRoutes.push(...Array.from(generatedRoutes));
|
||||
|
||||
for (const [path, content] of Object.entries(output)) {
|
||||
additionalOutputFiles.push(
|
||||
additionalHtmlOutputFiles.set(
|
||||
path,
|
||||
createOutputFileFromText(path, content, BuildOutputFileType.Browser),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
additionalOutputFiles.push(...additionalHtmlOutputFiles.values());
|
||||
|
||||
// Augment the application with service worker support
|
||||
// If localization is enabled, service worker is handled in the inlining process.
|
||||
if (serviceWorker) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user