Make Ruby Sass the default, but use SassC if available. Addresses #1648

This commit is contained in:
Thomas Reynolds 2015-11-27 15:41:42 -08:00
parent b4697e4541
commit 6de88a832e
4 changed files with 17 additions and 11 deletions

View file

@ -13,6 +13,7 @@ gem 'cucumber', '~> 2.0', require: false
# Optional middleman dependencies, included for tests # Optional middleman dependencies, included for tests
gem 'haml', '>= 4.0.5', require: false gem 'haml', '>= 4.0.5', require: false
gem 'sassc', '~> 1.8'
gem 'coffee-script', '~> 2.2', require: false gem 'coffee-script', '~> 2.2', require: false
gem 'kramdown', '~> 1.2', require: false gem 'kramdown', '~> 1.2', require: false
gem 'slim', '>= 2.0', require: false gem 'slim', '>= 2.0', require: false

View file

@ -1,12 +1,5 @@
require 'sass' require 'sass'
SASS_MODULE = begin
require 'sassc'
::SassC
rescue LoadError => e
::Sass
end
module Middleman module Middleman
module Renderers module Renderers
# Sass renderer # Sass renderer
@ -59,11 +52,17 @@ module Middleman
def evaluate(context, _) def evaluate(context, _)
@context ||= context @context ||= context
@engine = SASS_MODULE::Engine.new(data, sass_options) sass_module = if defined?(::SassC)
::SassC
else
::Sass
end
@engine = sass_module::Engine.new(data, sass_options)
begin begin
@engine.render @engine.render
rescue SASS_MODULE::SyntaxError => e rescue sass_module::SyntaxError => e
::Sass::SyntaxError.exception_to_css(e) ::Sass::SyntaxError.exception_to_css(e)
end end
end end

View file

@ -105,7 +105,13 @@ module Middleman
end end
end end
::SassC::Script::Functions.send :include, ::Middleman::Sass::Functions SASS_MODULE = if defined?(::SassC)
::SassC
else
::Sass
end
SASS_MODULE::Script::Functions.send :include, ::Middleman::Sass::Functions
# module SASS_MODULE::Script::Functions # module SASS_MODULE::Script::Functions
# include ::Middleman::Sass::Functions # include ::Middleman::Sass::Functions

View file

@ -42,7 +42,7 @@ Gem::Specification.new do |s|
s.add_dependency('fastimage', ['~> 1.7.0']) s.add_dependency('fastimage', ['~> 1.7.0'])
# Minify CSS # Minify CSS
s.add_dependency('sassc', ['>= 1.6.0']) s.add_dependency('sass', ['>= 3.4'])
# Minify JS # Minify JS
s.add_dependency('uglifier', ['~> 2.6']) s.add_dependency('uglifier', ['~> 2.6'])