Sha256: 58d831543c8cfbb6f2f092b65dc2d6a98fc1258008c2c26464062b9b397431b2
Contents?: true
Size: 997 Bytes
Versions: 1
Compression:
Stored size: 997 Bytes
Contents
# frozen_string_literal: true require "propshaft/compiler" 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) } end private 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 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}" "#{comment_start}#{comment_end}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
propshaft-0.8.0 | lib/propshaft/compiler/source_mapping_urls.rb |