Class: Sprockets::Rails::SourcemappingUrlProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/rails/sourcemapping_url_processor.rb

Overview

Rewrites source mapping urls with the digested paths and protect against semicolon appending with a dummy comment line

Constant Summary collapse

REGEX =
/\/\/# sourceMappingURL=(.*\.map)/

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sprockets/rails/sourcemapping_url_processor.rb', line 8

def call(input)
  env     = input[:environment]
  context = env.context_class.new(input)
  data    = input[:data].gsub(REGEX) do |_match|
    sourcemap_logical_path = combine_sourcemap_logical_path(sourcefile: input[:name], sourcemap: $1)

    begin
      resolved_sourcemap_comment(sourcemap_logical_path, context: context)
    rescue Sprockets::FileNotFound
      removed_sourcemap_comment(sourcemap_logical_path, filename: input[:filename], env: env)
    end
  end

  { data: data }
end