Skip to content

Commit

Permalink
make WebpackAssetFinder#pathname do less
Browse files Browse the repository at this point in the history
  • Loading branch information
kylefox committed Feb 22, 2020
1 parent 56989a8 commit d232345
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/inline_svg/webpack_asset_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ def self.find_asset(filename)

def initialize(filename)
@filename = filename
@asset_path = Webpacker.manifest.lookup(@filename)
end

def pathname
file_path = Webpacker.instance.manifest.lookup(@filename)
return unless file_path
return if @asset_path.blank?

if Webpacker.dev_server.running?
dev_server_asset(file_path)
else
public_path = Webpacker.config.public_path
return unless public_path

File.join(public_path, file_path)
dev_server_asset(@asset_path)
elsif Webpacker.config.public_path.present?
File.join(Webpacker.config.public_path, @asset_path)
end
end

Expand Down

0 comments on commit d232345

Please sign in to comment.