DEV: Ensure Embroider sourcemaps are collected by Sprockets (#23468)

Names of sourcemaps are not necessarily equal to the js file names. Instead, we can check the `sourceMappingURL` comment to find the map's filename.
This commit is contained in:
David Taylor 2023-09-07 22:20:52 +01:00 committed by GitHub
parent 754cd9cd22
commit 75ce01a69b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -59,6 +59,10 @@ module EmberCli
{}
end
def self.parse_source_map_path(file)
File.read("#{dist_dir}/assets/#{file}")[%r{^//# sourceMappingURL=(.*)$}, 1]
end
def self.is_ember_cli_asset?(name)
assets.include?(name) || name.start_with?("chunk.")
end

View File

@ -53,9 +53,9 @@ task "assets:precompile:before": "environment" do
require "digest/sha1"
# Add ember cli chunks
Rails.configuration.assets.precompile.push(
*EmberCli.script_chunks.values.flatten.flat_map { |name| ["#{name}.js", "#{name}.map"] },
)
chunk_files = EmberCli.script_chunks.values.flatten.map { |name| "#{name}.js" }
map_files = chunk_files.map { |file| EmberCli.parse_source_map_path(file) }
Rails.configuration.assets.precompile.push(*chunk_files, *map_files)
end
task "assets:precompile:css" => "environment" do