Serve script tags from Vite's development server - #35
Merged
Conversation
`include_ember_script_tags` always read the output of `ember build`, so a Vite-based application served by ember-cli-rails's development server (tricknotes/ember-cli-rails#653) could not use the asset helpers without opting out of the server — and with it, out of fast reloads. When the application is served by the development server (feature-detected, so older ember-cli-rails releases keep their behavior), read `index.html` from the server instead of a build directory and emit the startup tags with root-relative URLs rewritten to absolute URLs on the server, the same way ember-cli-rails serves the document itself. Nothing is built, so a change to the application is picked up by reloading the page. The extraction shared with the build-directory path now also leaves protocol-relative (`//`) URLs alone, and `include_ember_stylesheet_tags` raises its Vite guidance for development-server applications too (their `dist` may not exist, so the Vite detection alone would miss them). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tricknotes
force-pushed
the
dev-server-script-tags
branch
from
September 2, 2026 09:23
17a46d5 to
7b97a0a
Compare
Point the development dependency back at the released ember-cli-rails. The release carries no development-server API, so the examples covering it stand in plain doubles for `EmberCli::App` and `EmberCli::DevServer`; the helper itself already feature-detects the API with `respond_to?`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tricknotes
pushed a commit
to tricknotes/ember-cli-rails
that referenced
this pull request
Sep 3, 2026
With the ember-cli-rails-assets release carrying tricknotes/ember-cli-rails-assets#35, `include_ember_script_tags` reads `index.html` from the development server and emits absolute URLs pointing at it, so the helpers no longer require `dev_server: false`. Update the passages that said the helpers always read the build output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tricknotes
force-pushed
the
dev-server-script-tags
branch
from
September 3, 2026 16:07
912a51c to
5c45178
Compare
Merged
tricknotes
pushed a commit
to tricknotes/ember-cli-rails
that referenced
this pull request
Sep 3, 2026
With the ember-cli-rails-assets release carrying tricknotes/ember-cli-rails-assets#35, `include_ember_script_tags` reads `index.html` from the development server and emits absolute URLs pointing at it, so the helpers no longer require `dev_server: false`. Update the passages that said the helpers always read the build output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tricknotes
pushed a commit
to tricknotes/ember-cli-rails
that referenced
this pull request
Sep 4, 2026
With the ember-cli-rails-assets release carrying tricknotes/ember-cli-rails-assets#35, `include_ember_script_tags` reads `index.html` from the development server and emits absolute URLs pointing at it, so the helpers no longer require `dev_server: false`. Update the passages that said the helpers always read the build output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
include_ember_script_tagsalways reads the output ofember build, so a Vite-based application served by ember-cli-rails's development server (tricknotes/ember-cli-rails#653) cannot use the asset helpers without opting out of the server withdev_server: false— and with it, out of fast reloads: embedding the app into Rails-owned HTML then requires a full build (8–10 seconds in my measurements) before a change shows up.When the application is served by the development server, the helper now reads
index.htmlfrom the server instead of a build directory, and emits the startup tags with root-relative URLs rewritten to absolute URLs on the server — the same rewrite ember-cli-rails applies when it serves the document itself. Nothing is built, so a change to the application is picked up by reloading the page (about 550 ms from change to reflection in my measurements).Implementation notes
app.respond_to?(:dev_server?), so combinations with older ember-cli-rails releases (which have no development server) keep their current behavior. The development dependency stays on the released ember-cli-rails; the examples covering the new path stand in plain doubles for the development-server API until a release carries it.vite_startup_tags(html, prefix:). It now also leaves protocol-relative (//) URLs alone.include_ember_stylesheet_tagsraises its Vite guidance for development-server applications too: theirdistmay not exist, so the Vite detection alone would miss them.Verification
spec/helpersandspec/libpass against the released ember-cli-rails: 11 examples, 0 failures.spec/featuresexamples fail in my environment for browser-setup reasons, identically with and without this change (verified against a baseline), so please rely on CI for them.app/styles/app.cssis served after a plain reload.🤖 Generated with Claude Code