Repository navigation
Conversation
`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.
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ng add @angular/pwadecides between thepublicand legacysrc/assetslayouts withhost.exists(assetsDir), butTree.exists()only matches files, so the legacy branch never runs and pre-v18 layout projects get the manifest and icons in apublicdirectory 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
publicdirectory 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 existingassetsdirectory with the manifest referencing them asassets/icons/*. The workspace file is now written after the asset entry additions, which previously happened afterwriteWorkspace()and were never persisted. Projects using thepublicdirectory layout are unaffected.