Sha256: bd2ffe24e7bc47b965c315dcf96c55c0ae38306a1eec55435c5bc0ee841792a2
Contents?: true
Size: 874 Bytes
Versions: 2
Compression:
Stored size: 874 Bytes
Contents
# frozen_string_literal: true module Sprockets module Preprocessors # Private: Adds a default map to assets when one is not present # # If the input file already has a source map, it effectively returns the original # result. Otherwise it maps 1 for 1 lines original to generated. This is needed # Because other generators run after might depend on having a valid source map # available. class DefaultSourceMap def call(input) result = { data: input[:data] } map = input[:metadata][:map] if map.nil? || map.empty? result[:map] ||= [] input[:data].each_line.with_index do |_, index| line = index + 1 result[:map] << { source: input[:source_path], generated: [line , 0], original: [line, 0] } end end return result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprockets-4.0.0.beta4 | lib/sprockets/preprocessors/default_source_map.rb |
sprockets-4.0.0.beta3 | lib/sprockets/preprocessors/default_source_map.rb |