Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Prerender doesn't use the build options setting for the default "index.html" name #1585

@vmasek

Description

@vmasek

🐞 Bug report

Prerender builder seems to ignore the build options setting the default "index.html" name/location.

What modules are related to this issue?

  • builders

Is this a regression?

No

Description

From what I've seen the prerender

🔬 Minimal Reproduction

  1. Rename your index.html to something else, for example: index.original.html
  2. Set the correct name in angular.json configuration for projects.name.architect.build.options.index
    • in this case "index": "src/index.original.html",
  3. Try to prerender your application

🔥 Exception or Error


An unhandled exception occurred: ENOENT: no such file or directory, open 'C:\Users\user-name\WebstormProjects\my-project\dist\browser\index.html'

This is expected as dist\browser\index.html does not exist, but dist\browser\index.original.html does.

Possible solution

Replacing browserIndexOutputPath at line https://github.com/angular/universal/blob/f0a78c4792ebd6e4e920cda60552be123f7c6810/modules/builders/src/prerender/index.ts#L111
with path.join(outputPath, 'index.original.html') seems to fix the error, but only the "default" route is rendered and I don't even have it specified in routes I want to render.

It would be ideal if the prerender builder respected the setting set in the build options.

I'm open to PR but I need guidance determining the best solution and on how to get the builder options to the _renderUniversal function.

🌍 Your Environment


Angular CLI: 9.1.0
Node: 12.16.1
OS: win32 x64

Angular: 9.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.6
@angular-devkit/build-angular     0.901.0
@angular-devkit/build-optimizer   0.901.0
@angular-devkit/build-webpack     0.901.0
@angular-devkit/core              9.0.6
@angular-devkit/schematics        9.1.0
@angular/cdk                      9.2.0
@angular/flex-layout              9.0.0-beta.29
@ngtools/webpack                  9.1.0
@nguniversal/builders             9.0.2
@nguniversal/common               9.0.2
@nguniversal/express-engine       9.0.2
@schematics/angular               9.1.0
@schematics/update                0.901.0
rxjs                              6.5.4
typescript                        3.8.3
webpack                           4.42.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions