Skip to content

Find the assets nested in the build output - #45

Merged
tricknotes merged 3 commits into
mainfrom
find-nested-assets
Sep 18, 2026
Merged

tricknotes merged 3 commits into
mainfrom
find-nested-assets

Conversation

@tricknotes

@tricknotes tricknotes commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Fixes #24.

The asset map is built from dist/assets, but it only listed that directory's own children, so a file an addon ships in a subdirectory was represented by the subdirectory itself.
A document referencing one, such as <link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">, therefore failed with Failed to find assets matching.

Changes

  • Walk the whole dist/assets tree in EmberCli::Assets::DirectoryAssetMap, keying every file by its path within the directory (font-awesome/css/font-awesome.min.css) instead of listing only the top level
  • Resolve a reference in EmberCli::Assets::AssetMap by the longest trailing path that index.html and the asset map agree on, rather than by file name alone. A nested asset then resolves to the file it names rather than to whichever file happens to share its basename, and a reference carrying the build's rootURL still resolves

Verification

spec/lib and spec/helpers pass (20 examples).
Of the four new examples, the one covering the nested listing and the one covering a basename shared across directories fail without the change; the other two cover references that already resolved and guard the new matching.
The spec/features suite, which builds a real Ember application, was not run here.

The asset map is built from `dist/assets`, but it only listed that directory's own children, so a file an addon ships in a subdirectory was represented by the subdirectory itself.
A document referencing one, such as `<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">`, therefore failed with `Failed to find assets matching`.

Walk the whole tree and key every file by its path within the directory.
Resolving a reference now matches on the longest trailing path that `index.html` and the asset map agree on, so a nested asset resolves to the file it names rather than to whichever file happens to share its basename.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread lib/ember_cli/assets/asset_map.rb Outdated
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tricknotes
tricknotes marked this pull request as ready for review September 18, 2026 01:07
@tricknotes
tricknotes merged commit a821217 into main Sep 18, 2026
10 checks passed
@tricknotes
tricknotes deleted the find-nested-assets branch September 18, 2026 01:07
@tricknotes tricknotes mentioned this pull request Sep 18, 2026
tricknotes pushed a commit to tricknotes/ember-cli-rails that referenced this pull request Sep 18, 2026
`ember build` writes what an addon ships in a subdirectory of `assets` into that
subdirectory, and `index.html` refers to it by that path.
Listing the `assets` directory one level deep represented such a file by the
subdirectory that holds it, and matching a reference by its file name alone
resolved it to whichever file happened to share that name.

Represent every file by its path within `assets`, and resolve a reference by the
longest trailing path the document and the build output agree on.
A reference that carries the `assets` directory, or the application's `rootURL`,
still resolves.

This carries what the asset helpers gained in
tricknotes/ember-cli-rails-assets#45 into the code that now interprets the
build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to use CSS files that are more than one level deep in the assets folder

2 participants