Skip to content

Commit

Permalink
Improve log message
Browse files Browse the repository at this point in the history
  • Loading branch information
esasse committed Nov 7, 2023
1 parent bc433b8 commit 936cbf9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/propshaft/compiler/source_mapping_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ class Propshaft::Compiler::SourceMappingUrls < Propshaft::Compiler
SOURCE_MAPPING_PATTERN = %r{(//|/\*)# sourceMappingURL=(.+\.map)(\s*?\*\/)?\s*?\Z}

def compile(logical_path, input)
input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(asset_path($2, logical_path), $1, $3) }
@logical_path = logical_path
input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(asset_path($2), $1, $3) }
end

private
def asset_path(source_mapping_url, logical_path)
attr_reader :logical_path

def asset_path(source_mapping_url)
if logical_path.dirname.to_s == "."
source_mapping_url
else
Expand All @@ -22,7 +25,7 @@ def source_mapping_url(resolved_path, comment_start, comment_end)
if asset = assembly.load_path.find(resolved_path)
"#{comment_start}# sourceMappingURL=#{url_prefix}/#{asset.digested_path}#{comment_end}"
else
Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{resolved_path}"
Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{logical_path}"
"#{comment_start}#{comment_end}"
end
end
Expand Down

0 comments on commit 936cbf9

Please sign in to comment.