Skip to content

fix(@angular/pwa): support projects with the pre-v18 src/assets layout - #34734

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/pwa-legacy-assets-layout
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/pwa-legacy-assets-layout

Conversation

@MeAkib

@MeAkib MeAkib commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

ng add @angular/pwa decides between the public and legacy src/assets layouts with host.exists(assetsDir), but Tree.exists() only matches files, so the legacy branch never runs and pre-v18 layout projects get the manifest and icons in a public directory their build does not serve. The manifest link injected into index.html then 404s and the application is not installable, while the schematic reports success.

Detect the directory through its entries instead and restore the layout that worked before the public directory support was introduced: the manifest is written to the source root, where the asset entry added to the workspace configuration and the injected manifest link already point, and the icons are written to the existing assets directory with the manifest referencing them as assets/icons/*. The workspace file is now written after the asset entry additions, which previously happened after writeWorkspace() and were never persisted. Projects using the public directory layout are unaffected.

`ng add @angular/pwa` decides between the `public` and legacy `src/assets`
layouts with `host.exists(assetsDir)`, but `Tree.exists()` only matches
files, so the legacy branch never runs and pre-v18 layout projects get the
manifest and icons in a `public` directory their build does not serve. The
manifest link injected into index.html then 404s and the application is
not installable, while the schematic reports success.

Detect the directory through its entries instead and restore the layout
that worked before the `public` directory support was introduced: the
manifest is written to the source root, where the asset entry added to the
workspace configuration and the injected manifest link already point, and
the icons are written to the existing `assets` directory with the manifest
referencing them as `assets/icons/*`. The workspace file is now written
after the asset entry additions, which previously happened after
`writeWorkspace()` and were never persisted. Projects using the `public`
directory layout are unaffected.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PWA schematic to support the legacy src/assets project layout (pre-v18) alongside the newer layout. It detects the legacy layout by probing the assets directory for existing files or subdirectories, placing the manifest at the source root and the icons in the assets/icons directory. It also adds corresponding unit tests to verify this behavior. I have no feedback to provide as there are no review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant