class Propshaft::Compilers::SourceMappingUrls
Constants
- SOURCE_MAPPING_PATTERN
Attributes
assembly[R]
Public Class Methods
new(assembly)
click to toggle source
# File lib/propshaft/compilers/source_mapping_urls.rb, line 8 def initialize(assembly) @assembly = assembly end
Public Instance Methods
compile(logical_path, input)
click to toggle source
# File lib/propshaft/compilers/source_mapping_urls.rb, line 12 def compile(logical_path, input) input.gsub(SOURCE_MAPPING_PATTERN) { source_mapping_url(asset_path($2, logical_path), $1) } end
Private Instance Methods
asset_path(source_mapping_url, logical_path)
click to toggle source
# File lib/propshaft/compilers/source_mapping_urls.rb, line 17 def asset_path(source_mapping_url, logical_path) if logical_path.dirname.to_s == "." source_mapping_url else logical_path.dirname.join(source_mapping_url).to_s end end
source_mapping_url(resolved_path, comment)
click to toggle source
# File lib/propshaft/compilers/source_mapping_urls.rb, line 25 def source_mapping_url(resolved_path, comment) if asset = assembly.load_path.find(resolved_path) "#{comment}# sourceMappingURL=#{assembly.config.prefix}/#{asset.digested_path}" else Propshaft.logger.warn "Removed sourceMappingURL comment for missing asset '#{resolved_path}' from #{resolved_path}" nil end end