Keep assets hosted outside the build out of the asset lookup - #43
Merged
Merged
Conversation
Since assets are resolved from `dist/index.html`, every `<script src>` and `<link rel="stylesheet" href>` in that document is looked up in the build output by its basename. A document may also point at assets that the build does not produce, such as a stylesheet served by a font service or a script served by a CDN. Those have no entry in the build output, so the lookup raised `Failed to find assets matching`, and an inline `<script>` without a `src` raised a `TypeError` from `File.basename(nil)`. Emit a URL that resolves outside the build (one carrying a scheme, or a protocol-relative one) as it is, and skip a tag that references no asset at all. `prepend` mounts the build output onto a path or another host, so it no longer applies to those URLs either, matching how the Vite startup tags are already remapped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tricknotes
marked this pull request as ready for review
September 18, 2026 00:40
Merged
tricknotes
pushed a commit
to tricknotes/ember-cli-rails
that referenced
this pull request
Sep 18, 2026
A built `index.html` may point at assets the build does not produce, such as a stylesheet served by a font service or a script served by a CDN. They have no file to resolve against, and an inline `<script>` names no asset at all, so resolving every reference by its basename fails on both. Emit a URL that resolves outside the build as it is, and skip a tag that carries no URL. `prepend` mounts the build output onto a path or another host, so the readers take it and join it only onto the assets that point into the build, the way `startup_tags` already remaps a Vite build. This carries the behaviour the asset helpers gained in tricknotes/ember-cli-rails-assets#43 into the code that now interprets the build, and `StartupTags` shares the predicate that decides it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 18, 2026
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.
Fixes #25.
Since assets are resolved from
dist/index.html, every<script src>and<link rel="stylesheet" href>in that document is looked up in the build output by its basename.A document may also point at assets that the build does not produce, such as a stylesheet served by a font service or a script served by a CDN.
Those have no entry in the build output, so the lookup raises
Failed to find assets matching, and an inline<script>without asrcraises aTypeErrorfromFile.basename(nil).Changes
EmberCli::Assets::Url.remote?, which recognizes a URL that resolves outside the build: one carrying a scheme (https://example.com/app.css), and a protocol-relative one (//example.com/app.css)EmberCli::Assets::AssetMapas it is, and skip a tag that references no asset at all (an inline<script>)prependonto those URLs in the helpers:prependmounts the build output onto a path or another host, so it only applies to the URLs that point into the build. This matches how the Vite startup tags are already remappedVerification
spec/libandspec/helperspass (16 examples).The five new examples fail without the change: three raise from the lookup (two
BuildError, oneTypeError) and two showprependjoined onto a remote URL.The
spec/featuressuite, which builds a real Ember application, was not run here.