Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/angular/build/src/builders/application/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,16 @@ export async function normalizeOptions(
* If SSR is activated, create a distinct entry file for the `index.html`.
* This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
* if it exists (handling SSG).
*
* For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
*
* This approach can also be applied to service workers, where the `index.csr.html` is served instead of the prerendered `index.html`.
*/
const indexBaseName = path.basename(options.index);
indexOutput = ssrOptions && indexBaseName === 'index.html' ? INDEX_HTML_CSR : indexBaseName;
indexOutput =
(ssrOptions || prerenderOptions) && indexBaseName === 'index.html'
? INDEX_HTML_CSR
: indexBaseName;
} else {
indexOutput = options.index.output || 'index.html';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ export default async function () {
return;
}

await ng('build', projectName, '--configuration=production', '--prerender');
await ng('build', projectName, '--configuration=production', '--prerender', '--no-ssr');
await runExpects();

// Test also JIT mode.
await ng('build', projectName, '--configuration=development', '--prerender', '--no-aot');
await ng(
'build',
projectName,
'--configuration=development',
'--prerender',
'--no-ssr',
'--no-aot',
);

await runExpects();

async function runExpects(): Promise<void> {
Expand All @@ -136,6 +144,10 @@ export default async function () {
'lazy-two/index.html': 'lazy-two works!',
};

if (!useWebpackBuilder) {
expects['index.csr.html'] = '<app-root></app-root>';
}

const distPath = 'dist/' + projectName + '/browser';
for (const [filePath, fileMatch] of Object.entries(expects)) {
await expectFileToMatch(join(distPath, filePath), fileMatch);
Expand Down