Skip to content

Commit

Permalink
make env prefix for dev_server configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Dec 15, 2018
1 parent de916f3 commit f07bd94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/webpacker/dev_server.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Webpacker::DevServer
DEFAULT_ENV_PREFIX = "WEBPACKER_DEV_SERVER".freeze

# Configure dev server connection timeout (in seconds), default: 0.01
# Webpacker.dev_server.connect_timeout = 1
cattr_accessor(:connect_timeout) { 0.01 }
Expand Down Expand Up @@ -49,9 +51,13 @@ def pretty?
fetch(:pretty)
end

def env_prefix
config.dev_server.fetch(:env_prefix, DEFAULT_ENV_PREFIX)
end

private
def fetch(key)
ENV["WEBPACKER_DEV_SERVER_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
ENV["#{env_prefix}_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
end

def defaults
Expand Down

0 comments on commit f07bd94

Please sign in to comment.