Class: ViteRuby::DevServerProxy
- Inherits:
-
Rack::Proxy
- Object
- Rack::Proxy
- ViteRuby::DevServerProxy
- Extended by:
- Forwardable
- Defined in:
- lib/vite_ruby/dev_server_proxy.rb
Overview
Public: Allows to relay asset requests to the Vite development server.
Constant Summary collapse
- HOST_WITH_PORT_REGEX =
%r{^(.+?)(:\d+)/}
- VITE_DEPENDENCY_PREFIX =
"/@"
Instance Method Summary collapse
-
#initialize(app = nil, options = {}) ⇒ DevServerProxy
constructor
A new instance of DevServerProxy.
-
#perform_request(env) ⇒ Object
Rack: Intercept asset requests and send them to the Vite server.
Constructor Details
#initialize(app = nil, options = {}) ⇒ DevServerProxy
Returns a new instance of DevServerProxy.
10 11 12 13 14 |
# File 'lib/vite_ruby/dev_server_proxy.rb', line 10 def initialize(app = nil, = {}) @vite_ruby = .delete(:vite_ruby) || ViteRuby.instance [:streaming] = false if config.mode == "test" && !.key?(:streaming) super end |
Instance Method Details
#perform_request(env) ⇒ Object
Rack: Intercept asset requests and send them to the Vite server.
17 18 19 20 21 22 23 24 |
# File 'lib/vite_ruby/dev_server_proxy.rb', line 17 def perform_request(env) if vite_should_handle?(env) && dev_server_running? forward_to_vite_dev_server(env) super else @app.call(env) end end |