Skip to content

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

Closed

Description

@Raul52

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

Activity

  1. 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[/+] on Oct 4, 2024
  2. added a commit that references this issue on Oct 7, 2024
    e30edd5
  3. added
    freq1: low
    and removed on Oct 7, 2024
  4. added a commit that references this issue on Oct 7, 2024
    b166b70
  5. added 2 commits that reference this issue on Oct 7, 2024
    7de93e5
    dfd2d5c
  6. angular-automatic-lock-bot commented on Nov 7, 2024

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @schematics/angularfreq1: lowseverity3: brokentype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions