Skip to content

Commit 254182f

Browse files
committed
Move compiler configuration into configuraton class
1 parent 91f7fbe commit 254182f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/shakapacker/compiler.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ def webpack_env
106106

107107
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
108108

109-
env.merge("SHAKAPACKER_ASSET_HOST" => ENV.fetch("SHAKAPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
110-
"SHAKAPACKER_RELATIVE_URL_ROOT" => ENV.fetch("SHAKAPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
111-
"SHAKAPACKER_CONFIG" => instance.config_path.to_s)
109+
env.merge(
110+
"SHAKAPACKER_ASSET_HOST" => instance.config.asset_host,
111+
"SHAKAPACKER_RELATIVE_URL_ROOT" => instance.config.relative_url_root,
112+
"SHAKAPACKER_CONFIG" => instance.config_path.to_s
113+
)
112114
end
113115

114116
def bin_shakapacker_path

lib/shakapacker/configuration.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ def fetch(key)
116116
data.fetch(key, defaults[:shakapacker_precompile])
117117
end
118118

119+
def asset_host
120+
ENV.fetch("SHAKAPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host)
121+
end
122+
123+
def relative_url_root
124+
ENV.fetch("SHAKAPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root)
125+
end
126+
119127
private
120128
def data
121129
@data ||= load

0 commit comments

Comments
 (0)