angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

Allow selecting the default prerendered page for non-prerendered routes #28344

Closed aeslinger0 closed 1 month ago

aeslinger0 commented 2 months ago

Which @angular/* package(s) are relevant/related to the feature request?

compiler

Description

I have a set of routes that I prerender using the routesFile property, but for routes that are not specified in that file, the homepage flashes briefly. It would be nice if we could select a different page to show (like a generic loading page) or to configure it to not show a prerendered page at all.

Proposed solution

When a routesFile is specified, don't show a prerendered page for routes not in that file.

Alternatives considered

You could also override the default prerendered page that is displayed for routes not in the routesFile. Either by using some value in angular.json or just using the first (or last) entry in the routesFile as the default prerendered page.

alan-agius4 commented 2 months ago

Hi @aeslinger0, thanks for your request. However, I’m having some trouble understanding the issue.

You mentioned that the proposed solution is to avoid displaying a prerendered page for routes that aren't included. This is actually the current behavior.

Additionally, if you’re looking to implement a loading page, you can use an app shell. You can find more details here: Angular App Shell.

alan-agius4 commented 1 month ago

I'm sorry, but we don't understand the problem you are reporting.

If the problem persists, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use ng new repro-app to create a new project where you reproduce the problem.

aeslinger0 commented 1 month ago

@alan-agius4 I implemented app-shell like you suggested, but I must be missing something. I have "prerender": true and "ssr": false. I can see the shell contents in the main index.html as expected. However, if I add a route for the home page such as { path: '', loadComponent: () => import('src/app/dashboard/dashboard.component').then(x => x.DashboardComponent) },, then I see the prerendered content of dashboard instead of shell in the index.html. I believe this is why the dashboard content flashes for a moment for non-prerendered routes. How can I prerender the homepage, but still have the shell display for non-prerendered routes?

angular-automatic-lock-bot[bot] commented 4 days ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.