Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): prerender default view when no ro…
Browse files Browse the repository at this point in the history
…utes are defined

Prior to the commit, when no routes were defined the default view was not prerendering.

Closes #26317

(cherry picked from commit 6cf9342)
  • Loading branch information
alan-agius4 committed Nov 13, 2023
1 parent d9f7d43 commit 21549bd
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ export async function* extractRoutes(

const injector = applicationRef.injector;
const router = injector.get(Router);
const compiler = injector.get(Compiler);

// Extract all the routes from the config.
yield* getRoutesFromRouterConfig(router.config, compiler, injector);
if (router.config.length === 0) {
// In case there are no routes available
yield { route: '', success: true, redirect: false };
} else {
const compiler = injector.get(Compiler);
// Extract all the routes from the config.
yield* getRoutesFromRouterConfig(router.config, compiler, injector);
}
} finally {
platformRef.destroy();
}
Expand Down

0 comments on commit 21549bd

Please sign in to comment.