Remap a mounted Vite build's asset URLs onto the mount point - #666
Merged
Conversation
The `index.html` of a Vite build refers to its assets with root-relative URLs. When `mount_ember_app` served the build output from a path other than `/`, the document was returned as-is, so the browser requested `/assets/...` from the Rails root and got a 404 — or another application mounted there. Classic builds have the documented `rootURL` escape hatch, and `include_ember_script_tags` remaps via its `prepend:` option, but `mount_ember_app` / `render_ember_app` had no equivalent. `mount_ember_app` now records its mount point as a route default, `render_ember_app` passes it to `App#index_html`, and the document's root-relative `src` / `href` values are remapped onto the mount point, where `mount_ember_assets` serves the build output. References that already carry the mount point — a `rootURL` configured to match it — are left alone, as are classic builds and development-server-backed documents (their asset URLs point at the development server absolutely). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tricknotes
force-pushed
the
remap-mounted-assets
branch
from
September 4, 2026 11:46
aec3bbc to
be0b2d5
Compare
Merged
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.
Summary
The
index.htmlof a Vite build refers to its assets with root-relative URLs. Whenmount_ember_appserved the build output (Deploy::File) from a path other than/, the document was returned as-is, so the browser requested/assets/...from the Rails root and got a 404 — or another application mounted there. Classic builds have the documentedrootURLescape hatch, andinclude_ember_script_tagsremaps via itsprepend:option, butmount_ember_app/render_ember_apphad no equivalent.mount_ember_apprecords its mount point as a route default (ember_mount_point, alongside the existingember_app),render_ember_apppasses it toApp#index_html(new optionalmount_point:keyword — existing callers are unaffected), and the document's root-relativesrc/hrefvalues are remapped onto the mount point, wheremount_ember_assetsserves the build outputrootURLconfigured to match it — are left alone, as are protocol-relative and absolute URLs, classic builds, and development-server-backed documents (their asset URLs point at the development server absolutely, so there is nothing left to remap)rootURLwalkthrough to classic builds; CHANGELOG entry under the unreleased sectionVerification
App#index_htmlexamples cover the remap, the already-prefixed/protocol-relative/absolute skips, the root mount, and classic builds/no-block/document references its scripts under/no-block/(previously they leaned on the second copy of the application mounted at/)spec/libpasses (the one local failure is the known Chrome-dependentApp#testexample, green on CI); thejs: falsefeature scenarios pass locally, including the trailing-slash redirects