Skip to content

Commit

Permalink
checking if webpacker is used before defining rescue statement with w…
Browse files Browse the repository at this point in the history
…ebpacker manifest missing exception
  • Loading branch information
morozovm committed Sep 10, 2017
1 parent 2073c96 commit 56adeef
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ def self.server_bundle_js_file_path
return @server_bundle_path if @server_bundle_path && !Rails.env.development?

bundle_name = ReactOnRails.configuration.server_bundle_js_file
@server_bundle_path = begin
bundle_js_file_path(bundle_name)
rescue ActiveSupport::Inflector.safe_constantize("Webpacker::Manifest::MissingEntryError")
Rails.root.join(File.join(Webpacker.config.public_output_path, bundle_name)).to_s
end
@server_bundle_path = if using_webpacker?
begin
bundle_js_file_path(bundle_name)
rescue Webpacker::Manifest::MissingEntryError
Rails.root.join(File.join(Webpacker.config.public_output_path,
bundle_name)).to_s
end
else
bundle_js_file_path(bundle_name)
end
end

def self.bundle_js_file_path(bundle_name)
Expand Down

0 comments on commit 56adeef

Please sign in to comment.