Class: EmberCli::Deploy::DevServer
- Inherits:
-
Object
- Object
- EmberCli::Deploy::DevServer
- Defined in:
- lib/ember_cli/deploy/dev_server.rb
Overview
Serves an Ember application from its Vite development server instead of
from the dist directory written by ember build.
The index.html served by the development server refers to its assets
(/@vite/client included) with root-relative URLs. Rails serves the
document from its own origin, so those URLs are rewritten to absolute
URLs pointing at the development server. Loading them from there means
the Vite client opens its HMR WebSocket against the development server
directly, without Rails proxying it.
Constant Summary collapse
- ROOT_RELATIVE_URL =
%r{(\s)(src|href)=(["'])/(?!/)}i
Instance Method Summary collapse
- #index_html ⇒ Object
-
#initialize(app) ⇒ DevServer
constructor
A new instance of DevServer.
- #mountable? ⇒ Boolean
- #to_rack ⇒ Object
Constructor Details
#initialize(app) ⇒ DevServer
Returns a new instance of DevServer.
18 19 20 |
# File 'lib/ember_cli/deploy/dev_server.rb', line 18 def initialize(app) @app = app end |
Instance Method Details
#index_html ⇒ Object
30 31 32 |
# File 'lib/ember_cli/deploy/dev_server.rb', line 30 def index_html rewrite_root_relative_urls(dev_server.index_html) end |
#mountable? ⇒ Boolean
22 23 24 |
# File 'lib/ember_cli/deploy/dev_server.rb', line 22 def mountable? true end |
#to_rack ⇒ Object
26 27 28 |
# File 'lib/ember_cli/deploy/dev_server.rb', line 26 def to_rack DevServerProxy.new(app) end |