Skip to content

Commit

Permalink
Fix @import source maps in sassc processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Horth committed Oct 4, 2016
1 parent 55b8c83 commit fbcfd33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
19 changes: 5 additions & 14 deletions lib/sprockets/sassc_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ def call(input)
options = engine_options(input, context)
engine = Autoload::SassC::Engine.new(input[:data], options)

data = Utils.module_include(Autoload::SassC::Script::Functions, @functions) do
css = Utils.module_include(Autoload::SassC::Script::Functions, @functions) do
engine.render
end

match_data = data.match(/(.*)\n\/\*# sourceMappingURL=data:application\/json;base64,(.+) \*\//m)
css, map = match_data[1], Base64.decode64(match_data[2])

map = SourceMapUtils.combine_source_maps(
input[:metadata][:map],
change_source(SourceMapUtils.decode_json_source_map(map)["mappings"], input[:source_path])
)
map = SourceMapUtils.decode_json_source_map(engine.source_map)["mappings"]

engine.dependencies.each do |dependency|
context.metadata[:dependencies] << URIUtils.build_file_digest_uri(dependency.filename)
Expand All @@ -43,18 +37,15 @@ def call(input)

private

def change_source(mappings, source)
mappings.each { |m| m[:source] = source }
end

def engine_options(input, context)
merge_options({
filename: input[:filename],
syntax: self.class.syntax,
load_paths: input[:environment].paths,
importer: @importer_class,
source_map_embed: true,
source_map_file: '.',
source_map_contents: true,
source_map_file: "#{input[:filename]}.map",
omit_source_map_url: true,
sprockets: {
context: context,
environment: input[:environment],
Expand Down
2 changes: 1 addition & 1 deletion sprockets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rack-test", "~> 0.6"
s.add_development_dependency "rake", "~> 10.0"
s.add_development_dependency "sass", "~> 3.4"
s.add_development_dependency "sassc", "~> 1.7"
s.add_development_dependency "sassc", ">= 1.10.1", "< 2.0"
s.add_development_dependency "uglifier", "~> 2.3"
s.add_development_dependency "yui-compressor", "~> 0.12"

Expand Down

0 comments on commit fbcfd33

Please sign in to comment.