Skip to content

When using Angular with SSR without prerender there is no index.html generated #28574

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
1 task
Raul52 opened this issue Oct 4, 2024 · 1 comment · Fixed by #28585
Closed
1 task

When using Angular with SSR without prerender there is no index.html generated #28574

Raul52 opened this issue Oct 4, 2024 · 1 comment · Fixed by #28585
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@Raul52
Copy link

Raul52 commented Oct 4, 2024

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

Description

I am using Angular 18 with @angular/pwa

Inside ngsw-config.json , inside the assets group, you can find the initial app group.

By default, the content of the asset group is the following

    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/manifest.webmanifest",
          "/*.css",
          "/*.js"
        ]
      }
    }

If you use Angular with SSR and prefetch false, you will not get the index.html file in the dist folder. You will only get the index.csr.html

"build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "dist/prototype",
            "index": "src/index.html",
            "browser": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "public"
              }
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "server": "src/main.server.ts",
            "prerender": true,
            "ssr": {
              "entry": "server.ts"
            }
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kB",
                  "maximumError": "1MB"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kB",
                  "maximumError": "4kB"
                }
              ],
              "outputHashing": "all",
              "serviceWorker": "ngsw-config.json"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },

This seems like a bug.

I observed that suddenly we always make a request for the index.html bypassing the advantage of having it cached by the SW.
https://angular.dev/guide/ssr#using-angular-service-worker

Minimal Reproduction

ng new prototype
ng add @angular/pwa

change the prerender to false

ng build
node dist/prototype/server/server.mjs

Exception or Error

No response

Your Environment

Angular CLI: 18.2.7
Node: 22.5.1
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 18.2.7
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker, ssr

Package Version

@angular-devkit/architect 0.1802.7
@angular-devkit/build-angular 18.2.7
@angular-devkit/core 18.2.7
@angular-devkit/schematics 18.2.7
@schematics/angular 18.2.7
rxjs 7.8.1
typescript 5.5.4
zone.js 0.14.10

Anything else relevant?

No response

@Raul52 Raul52 changed the title When using Angular with SSR and without pre-render there is no index.html generated in the dist folder When using Angular with SSR without prerender there is no index.html generated Oct 4, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Oct 7, 2024
… group

Ensure `index.csr.html` is available for the service worker when using SSR/SSG.

Closes angular#28574
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Oct 7, 2024
… group

Ensure `index.csr.html` is available for the service worker when using SSR/SSG.

Closes angular#28574
dgp1130 pushed a commit that referenced this issue Oct 7, 2024
… group

Ensure `index.csr.html` is available for the service worker when using SSR/SSG.

Closes #28574
dgp1130 pushed a commit that referenced this issue Oct 7, 2024
… group

Ensure `index.csr.html` is available for the service worker when using SSR/SSG.

Closes #28574

(cherry picked from commit 7de93e5)
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 7, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants