Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/propshaft/compiler/source_mapping_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "propshaft/compiler"

class Propshaft::Compiler::SourceMappingUrls < Propshaft::Compiler
SOURCE_MAPPING_PATTERN = %r{(//|/\*)# sourceMappingURL=(.+\.map)(\s*?\*\/)?\s*?\Z}
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) }
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/assets/mapped/prefixed-source.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
5 changes: 5 additions & 0 deletions test/propshaft/compiler/source_mapping_urls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
compile_asset(find_asset("nested/another-source.js", fixture_path: "mapped"))
end

test "resolves prefix on source map filename" do
assert_match %r{//# sourceMappingURL=/assets/source.js-[a-z0-9]{40}\.map},
compile_asset(find_asset("prefixed-source.js", fixture_path: "mapped"))
end

test "missing source map" do
assert_no_match %r{sourceMappingURL},
compile_asset(find_asset("sourceless.js", fixture_path: "mapped"))
Expand Down