Sha256: 51c9cde5a3f9cb0f32ba069a261648ca53b64c3e3f3ba5267d5d76067359e644
Contents?: true
Size: 1.28 KB
Versions: 14
Compression:
Stored size: 1.28 KB
Contents
class Webpacker::DevServer DEFAULT_ENV_PREFIX = "WEBPACKER_DEV_SERVER".freeze # Configure dev server connection timeout (in seconds), default: 0.1 # Webpacker.dev_server.connect_timeout = 1 cattr_accessor(:connect_timeout) { 0.1 } attr_reader :config def initialize(config) @config = config end def running? if config.dev_server.present? Socket.tcp(host, port, connect_timeout: connect_timeout).close true else false end rescue false end def host fetch(:host) end def port fetch(:port) end def https? case fetch(:https) when true, "true", Hash true else false end end def protocol https? ? "https" : "http" end def host_with_port "#{host}:#{port}" end def pretty? fetch(:pretty) end def hmr? fetch(:hmr) end def inline_css? case fetch(:inline_css) when false, "false" false else true end end def env_prefix config.dev_server.fetch(:env_prefix, DEFAULT_ENV_PREFIX) end private def fetch(key) return nil unless config.dev_server.present? ENV["#{env_prefix}_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key]) end def defaults config.send(:defaults)[:dev_server] || {} end end
Version data entries
14 entries across 14 versions & 1 rubygems