Skip to content

Default route is not SSG'ed #26317

@9kubczas4

Description

@9kubczas4

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I've created new ng v17 app, run npm run build and in the result 0 pages were prerendered.
Then I added one route /test, run once again npm run build and in the result only /test page was prerendered.

I know that it's not a production scenario, but what if someone wants to have only the default root path - / or in other word an empty array of the routes.
Shouldn't / be prerendered by default?
If not then maybe would be nice to display some warning in the console to say that there are no routes configured, but the prerendering is requested, please add some routes (including /)..

I was able to implement the workaround. I needed to change angular.json from:
"prerender": true,
to:

"prerender": {
  "routesFile": "routes.txt"
},

And the routes.txt should have root path like below:
/
After applying above changes / and /test routes were prerendered.

Minimal Reproduction

  1. install cli in v17
  2. ng new
  3. ng build
  4. In console there will be information that Prerendered 0 static route.

Exception or Error

No response

Your Environment

Angular CLI: 17.0.0
Node: 18.15.0
Package Manager: npm 9.5.0
OS: darwin arm64

Angular: 17.0.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0
@angular-devkit/build-angular   17.0.0
@angular-devkit/core            17.0.0
@angular-devkit/schematics      17.0.0
@angular/cli                    17.0.0
@angular/ssr                    17.0.0
@schematics/angular             17.0.0
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions