lib/vite_ruby.rb in vite_ruby-3.2.11 vs lib/vite_ruby.rb in vite_ruby-3.2.12
- old
+ new
@@ -30,11 +30,11 @@
}
class << self
extend Forwardable
- def_delegators :instance, :config, :commands, :digest, :env, :run, :run_proxy?
+ def_delegators :instance, :config, :configure, :commands, :digest, :env, :run, :run_proxy?
def_delegators :config, :mode
def instance
@instance ||= new
end
@@ -83,11 +83,11 @@
# Public: Returns true if the Vite development server is currently running.
# NOTE: Checks only once every second since every lookup calls this method.
def dev_server_running?
return false unless run_proxy?
- return true if defined?(@running_at) && @running_at && Time.now - @running_at < 1
+ return true if @running_at && Time.now - @running_at < 1
Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
@running_at = Time.now
true
rescue StandardError
@@ -126,14 +126,19 @@
end
# Public: Current instance configuration for Vite.
def config
unless defined?(@config)
- @config = ViteRuby::Config.resolve_config(**@config_options)
+ configure
@config.load_ruby_config
end
@config
+ end
+
+ # Public: Allows overriding the configuration for this instance.
+ def configure(**options)
+ @config = ViteRuby::Config.resolve_config(**@config_options, **options)
end
# Public: Enables looking up assets managed by Vite using name and type.
def manifest
@manifest ||= ViteRuby::Manifest.new(self)