Skip to content

Commit

Permalink
fix: prevent error when using a proc in asset_host (close #202) (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElMassimo authored Apr 14, 2022
1 parent e75d5f1 commit cb23a81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion vite_rails/lib/vite_rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module ViteRails::Config
# Override: Default values for a Rails application.
def config_defaults
require 'rails'
asset_host = Rails.application&.config&.action_controller&.asset_host
super(
asset_host: Rails.application&.config&.action_controller&.asset_host,
asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
mode: Rails.env.to_s,
root: Rails.root || Dir.pwd,
)
Expand Down
3 changes: 2 additions & 1 deletion vite_rails_legacy/lib/vite_rails_legacy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module ViteRailsLegacy::Config
# Override: Default values for a Rails application.
def config_defaults
require 'rails'
asset_host = Rails.application&.config&.action_controller&.asset_host
super(
asset_host: Rails.application&.config&.action_controller&.asset_host,
asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
mode: Rails.env.to_s,
root: Rails.root || Dir.pwd,
)
Expand Down
2 changes: 1 addition & 1 deletion vite_ruby/lib/vite_ruby/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def config_defaults(asset_host: nil, mode: ENV.fetch('RACK_ENV', 'development'),
'config_path' => option_from_env('config_path') || DEFAULT_CONFIG.fetch('config_path'),
'mode' => option_from_env('mode') || mode,
'root' => option_from_env('root') || root,
}
}.select { |_, value| value }
end

# Internal: Used to load a JSON file from the specified path.
Expand Down

0 comments on commit cb23a81

Please sign in to comment.