Skip to content

Commit

Permalink
Have to keep building the input
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed May 17, 2024
1 parent 7dbfb9a commit 9c0d3ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion benchmarks/css_asset_urls
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ compiler = Propshaft::Compiler::CssAssetUrls.new(assembly)

Benchmark.ips do |x|
x.config(time: 5, warmup: 2)
x.report("compile") { compiler.compile(asset.logical_path, asset.content) }
x.report("compile") { compiler.compile(asset, asset.content) }
end
4 changes: 2 additions & 2 deletions lib/propshaft/compiler/css_asset_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class Propshaft::Compiler::CssAssetUrls < Propshaft::Compiler
ASSET_URL_PATTERN = /url\(\s*["']?(?!(?:\#|%23|data|http|\/\/))([^"'\s?#)]+)([#?][^"')]+)?\s*["']?\)/

def compile(asset)
asset.content.gsub(ASSET_URL_PATTERN) { asset_url resolve_path(asset.logical_path.dirname, $1), asset.logical_path, $2, $1 }
def compile(asset, input)
input.gsub(ASSET_URL_PATTERN) { asset_url resolve_path(asset.logical_path.dirname, $1), asset.logical_path, $2, $1 }
end

def referenced_by(asset)
Expand Down
4 changes: 2 additions & 2 deletions lib/propshaft/compiler/source_mapping_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class Propshaft::Compiler::SourceMappingUrls < Propshaft::Compiler
SOURCE_MAPPING_PATTERN = %r{(//|/\*)# sourceMappingURL=(.+\.map)(\s*?\*\/)?\s*?\Z}

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

private
Expand Down
2 changes: 1 addition & 1 deletion lib/propshaft/compilers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def compile(asset)
if relevant_registrations = registrations[asset.content_type.to_s]
asset.content.dup.tap do |input|
relevant_registrations.each do |compiler|
input.replace compiler.new(assembly).compile(asset)
input.replace compiler.new(assembly).compile(asset, input)
end
end
else
Expand Down

0 comments on commit 9c0d3ef

Please sign in to comment.