Prerendering routes not working when switching from `@angular-devkit/build-angular:application` to `@nx/angular:application`
Closed this issue · 0 comments
Current Behavior
Versions:
Nx: 20.2.1
Angular: 19.0.4
When I create a new project with:
npx create-nx-workspace@latest test
NX Let's create a new workspace [https://nx.dev/getting-started/intro]
✔ Which stack do you want to use? · angular
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · frontend
✔ Which bundler would you like to use? · esbuild
✔ Default stylesheet format · scss
✔ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? · Yes
✔ Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application? · No
✔ Test runner to use for end to end (E2E) tests · playwright
✔ Which CI provider would you like to use? · skip
✔ Would you like remote caching to make your build faster? · skip
And setup prerendering like this:
apps/frontend/project.json
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:application",
"prerender": {
"discoverRoutes": false,
"routesFile": "apps/frontend/routes.txt"
},
},
}
apps/frontend/routes.txt
/
/home
/blog
/customers
It works fine:
nx build frontend
> nx run frontend:build:production
Browser bundles
Initial chunk files | Names | Raw size | Estimated transfer size
chunk-NN72D66U.js | - | 159.05 kB | 46.74 kB
main-H6DOJEGB.js | main | 90.77 kB | 23.22 kB
polyfills-FFHMD2TL.js | polyfills | 34.52 kB | 11.28 kB
styles-5INURTSO.css | styles | 0 bytes | 0 bytes
| Initial total | 284.34 kB | 81.24 kB
Lazy chunk files | Names | Raw size | Estimated transfer size
chunk-KJJNDZN2.js | nx-welcome-component | 74 bytes | 74 bytes
Server bundles
Initial chunk files | Names | Raw size
server.mjs | server | 1.34 MB |
chunk-XDR4RVNH.mjs | - | 600.48 kB |
polyfills.server.mjs | polyfills.server | 268.60 kB |
chunk-5DWPOUBR.mjs | - | 139.81 kB |
chunk-RFT6F4MJ.mjs | - | 19.19 kB |
chunk-S6KH3LOX.mjs | - | 2.77 kB |
main.server.mjs | main.server | 1.01 kB |
Lazy chunk files | Names | Raw size
chunk-FE3ZEMPP.mjs | xhr2 | 12.07 kB |
chunk-GWOROCXO.mjs | nx-welcome-component | 160 bytes |
Prerendered 4 static routes.
Application bundle generation complete. [2.441 seconds]
But as soon as I switch to the @nx/angular:appliation
executor, it always only prerenders 0 routes suddenly:
apps/frontend/project.json
"targets": {
"build": {
"executor": "@nx/angular:application",
"prerender": {
"discoverRoutes": false,
"routesFile": "apps/frontend/routes.txt"
},
},
}
nx build frontend
> nx run frontend:build:production
Browser bundles
Initial chunk files | Names | Raw size | Estimated transfer size
chunk-NN72D66U.js | - | 159.05 kB | 46.74 kB
main-H6DOJEGB.js | main | 90.77 kB | 23.22 kB
polyfills-FFHMD2TL.js | polyfills | 34.52 kB | 11.28 kB
styles-5INURTSO.css | styles | 0 bytes | 0 bytes
| Initial total | 284.34 kB | 81.24 kB
Lazy chunk files | Names | Raw size | Estimated transfer size
chunk-KJJNDZN2.js | nx-welcome-component | 74 bytes | 74 bytes
Server bundles
Initial chunk files | Names | Raw size
server.mjs | server | 1.34 MB |
chunk-XDR4RVNH.mjs | - | 600.48 kB |
polyfills.server.mjs | polyfills.server | 268.60 kB |
chunk-5DWPOUBR.mjs | - | 139.81 kB |
chunk-RFT6F4MJ.mjs | - | 19.19 kB |
chunk-S6KH3LOX.mjs | - | 2.77 kB |
main.server.mjs | main.server | 1.01 kB |
Lazy chunk files | Names | Raw size
chunk-FE3ZEMPP.mjs | xhr2 | 12.07 kB |
chunk-GWOROCXO.mjs | nx-welcome-component | 160 bytes |
Prerendered 0 static routes.
Application bundle generation complete. [1.947 seconds]
Expected Behavior
It should prerender the same amount of routes as in the case with the @angular-devkit/build-angular:application
executor
GitHub Repo
https://github.com/webtsofficial/nx-ssr-prerender-bug
Steps to Reproduce
-
npx create-nx-workspace@latest test
NX Let's create a new workspace [https://nx.dev/getting-started/intro]
✔ Which stack do you want to use? · angular
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · frontend
✔ Which bundler would you like to use? · esbuild
✔ Default stylesheet format · scss
✔ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? · Yes
✔ Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application? · No
✔ Test runner to use for end to end (E2E) tests · playwright
✔ Which CI provider would you like to use? · skip
✔ Would you like remote caching to make your build faster? · skip -
switch from
@angular-devkit/build-angular:application
to@nx/angular:application
-
Configure prerendering with a
routes.txt
file:
"prerender": {
"discoverRoutes": false,
"routesFile": "apps/frontend/routes.txt"
}, -
run the build command and se, that 0 routes were prerendered
Nx Report
NX Report complete - copy this into the issue template
Node : 20.18.0
OS : darwin-arm64
Native Target : aarch64-macos
npm : 10.8.2
nx (global) : 20.0.0
nx : 20.2.1
@nx/js : 20.2.1
@nx/jest : 20.2.1
@nx/eslint : 20.2.1
@nx/workspace : 20.2.1
@nx/angular : 20.2.1
@nx/devkit : 20.2.1
@nx/eslint-plugin : 20.2.1
@nx/playwright : 20.2.1
@nx/vite : 20.2.1
@nx/web : 20.2.1
@nx/webpack : 20.2.1
typescript : 5.6.3
---------------------------------------
Registered Plugins:
@nx/playwright/plugin
@nx/eslint/plugin
---------------------------------------
Community plugins:
angular-eslint : 19.0.1
Failure Logs
Package Manager Version
npm 10.8.2
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
No response