Make Ruby Sass the default, but use SassC if available. Addresses #1648
This commit is contained in:
parent
b4697e4541
commit
6de88a832e
4 changed files with 17 additions and 11 deletions
1
Gemfile
1
Gemfile
|
@ -13,6 +13,7 @@ gem 'cucumber', '~> 2.0', require: false
|
|||
|
||||
# Optional middleman dependencies, included for tests
|
||||
gem 'haml', '>= 4.0.5', require: false
|
||||
gem 'sassc', '~> 1.8'
|
||||
gem 'coffee-script', '~> 2.2', require: false
|
||||
gem 'kramdown', '~> 1.2', require: false
|
||||
gem 'slim', '>= 2.0', require: false
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
require 'sass'
|
||||
|
||||
SASS_MODULE = begin
|
||||
require 'sassc'
|
||||
::SassC
|
||||
rescue LoadError => e
|
||||
::Sass
|
||||
end
|
||||
|
||||
module Middleman
|
||||
module Renderers
|
||||
# Sass renderer
|
||||
|
@ -59,11 +52,17 @@ module Middleman
|
|||
def evaluate(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
|
||||
@engine.render
|
||||
rescue SASS_MODULE::SyntaxError => e
|
||||
rescue sass_module::SyntaxError => e
|
||||
::Sass::SyntaxError.exception_to_css(e)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,7 +105,13 @@ module Middleman
|
|||
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
|
||||
# include ::Middleman::Sass::Functions
|
||||
|
|
|
@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency('fastimage', ['~> 1.7.0'])
|
||||
|
||||
# Minify CSS
|
||||
s.add_dependency('sassc', ['>= 1.6.0'])
|
||||
s.add_dependency('sass', ['>= 3.4'])
|
||||
|
||||
# Minify JS
|
||||
s.add_dependency('uglifier', ['~> 2.6'])
|
||||
|
|
Loading…
Reference in a new issue