Serve Vite-based Ember apps from development server - #653
Draft
tricknotes wants to merge 1 commit into
Draft
Conversation
Vite-based Ember applications (`ember-cli >= 6.8`) were built once, synchronously, on the first request in `development`, so picking up a change meant restarting Rails. The classic (Broccoli-based) build avoids that with `ember build --watch` and `ember-cli-rails-addon`, neither of which is available to the Vite-based build. Serve those applications from Vite's own development server instead -- the one the blueprint's `npm start` script runs. `EmberCli::DevServer` starts it on the first request, waits for it to accept connections, and signals its process group when Rails exits. If something is already listening on the configured address, it is used as-is, so a fixed `port` lets several Rails workers, or a hand-started `npm start`, share one server. `EmberCli::Deploy::DevServer` reads `index.html` over HTTP and rewrites its root-relative `src` and `href` attributes to absolute URLs on the development server. Loading `@vite/client` from there is what makes the Vite client open its HMR WebSocket against the development server directly, so Rails never proxies the socket. Assets the application references relatively are still requested from Rails, and `EmberCli::DevServerProxy` forwards them to the development server so they resolve the same way they do when served out of `dist`. The strategy is chosen by default only for Vite-based applications in `development`, and is configured -- or disabled -- with the `dev_server` option. `test` and `production` continue to be served from the output of `ember build`, and the classic build is untouched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RvmVfpMX8Dou7euMFAyzf4
tricknotes
marked this pull request as draft
August 31, 2026 12:21
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
Add support for serving Vite-based Ember applications (generated with
ember-cli >= 6.8) from Vite's own development server in development mode, enabling hot module reloading without restarting Rails.Key Changes
New
DevServerclass (lib/ember_cli/dev_server.rb): Manages the Vite development server lifecycle for a single Ember applicationget,head,options_request) to fetch assets and HTML from the serverNew
DevServerProxyRack middleware (lib/ember_cli/dev_server_proxy.rb): Proxies requests to the development serverNew
Deploy::DevServerstrategy (lib/ember_cli/deploy/dev_server.rb): Serves applications from the development serverindex.htmlto absolute URLs pointing at the development serverEnhanced
Appclass (lib/ember_cli/app.rb):dev_server?method to detect when an app should use the development serverdev_serverproperty to lazily initialize theDevServerDeploy::DevServerstrategy by default for Vite-based apps in developmentdev_serverconfiguration option to customize host, port, and timeoutEnhanced
Shellclass (lib/ember_cli/shell.rb):start_dev_servermethod to spawn the Vite development server in a separate process groupdev_server_running?method to check server statusEnhanced
Commandclass (lib/ember_cli/command.rb): Addsdev_servermethod to construct the Vite CLI commandEnhanced
PathSetclass (lib/ember_cli/path_set.rb): Addsviteproperty to locate the Vite executableComprehensive test coverage: Includes unit tests for all new classes and integration tests verifying the full request flow
Notable Implementation Details
index.htmlare rewritten to absolute URLs so the browser loads Vite's HMR client directly from the development server, not through Railsnpm startworkflowshttps://claude.ai/code/session_01RvmVfpMX8Dou7euMFAyzf4