Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain sourcemap file extensions #171

Merged
Merged
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/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def digested_path
if already_digested?
logical_path
else
logical_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
logical_path.sub(/\.(\w+(\.map)?)$/) { |ext| "-#{digest}#{ext}" }
end
end

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions test/propshaft/asset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class Propshaft::AssetTest < ActiveSupport::TestCase

assert_equal "file-not.digested-e206c34fe404c8e2f25d60dd8303f61c02b8d381.css",
find_asset("file-not.digested.css").digested_path.to_s

assert_equal "file-is-a-sourcemap-da39a3ee5e6b4b0d3255bfef95601890afd80709.js.map",
find_asset("file-is-a-sourcemap.js.map").digested_path.to_s
end

test "value object equality" do
Expand Down
12 changes: 6 additions & 6 deletions test/propshaft/compiler/source_mapping_urls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
end

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

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

Expand All @@ -38,9 +38,9 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
end

test "sourceMappingURL not at the beginning of the line, but at end of file, is processed" do
assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start.js-[a-z0-9]{40}\.map},
assert_match %r{//# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.js.map},
compile_asset(find_asset("sourceMappingURL-not-at-start.js", fixture_path: "mapped"))
assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start.css-[a-z0-9]{40}\.map \*/},
assert_match %r{/\*# sourceMappingURL=/assets/sourceMappingURL-not-at-start-[a-z0-9]{40}\.css.map \*/},
compile_asset(find_asset("sourceMappingURL-not-at-start.css", fixture_path: "mapped"))
end

Expand All @@ -56,7 +56,7 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
test "relative url root" do
@options.relative_url_root = "/url-root"

assert_match %r{//# sourceMappingURL=/url-root/assets/source.js-[a-z0-9]{40}\.map},
assert_match %r{//# sourceMappingURL=/url-root/assets/source-[a-z0-9]{40}\.js.map},
compile_asset(find_asset("source.js", fixture_path: "mapped"))
end

Expand Down