Revert "Merge pull request #2125 from vikhyat/css-variables"

This reverts commit b537de3ca5, reversing
changes made to b925827e5b.
This commit is contained in:
Régis Hanol
2014-04-01 16:24:29 +02:00
parent b537de3ca5
commit 77a8a4083a
60 changed files with 178 additions and 133 deletions
-71
View File
@@ -1,71 +0,0 @@
# This custom importer is used for site customizations. This is similar to the
# Sprockets::SassImporter implementation provided in sass-rails since that is used
# during asset precompilation.
class DiscourseSassImporter < Sass::Importers::Filesystem
GLOB = /\*|\[.+\]/
def initialize(root)
@root = Rails.root.join('app', 'assets', 'stylesheets').to_s
@same_name_warnings = Set.new
end
def extensions
{
'css' => :scss,
'css.scss' => :scss,
'css.sass' => :sass,
'css.erb' => :scss,
'scss.erb' => :scss,
'sass.erb' => :sass,
'css.scss.erb' => :scss,
'css.sass.erb' => :sass
}.merge!(super)
end
def find_relative(name, base, options)
if name =~ GLOB
glob_imports(name, Pathname.new(base), options)
else
engine_from_path(name, File.dirname(base), options)
end
end
def find(name, options)
if name =~ GLOB
nil # globs must be relative
else
engine_from_path(name, root, options)
end
end
def each_globbed_file(glob, base_pathname, options)
Dir["#{base_pathname}/#{glob}"].sort.each do |filename|
next if filename == options[:filename]
yield filename # assume all matching files are requirable
end
end
def glob_imports(glob, base_pathname, options)
contents = ""
each_globbed_file(glob, base_pathname.dirname, options) do |filename|
unless File.directory?(filename)
contents << "@import #{Pathname.new(filename).relative_path_from(base_pathname.dirname).to_s.inspect};\n"
end
end
return nil if contents.empty?
Sass::Engine.new(contents, options.merge(
filename: base_pathname.to_s,
importer: self,
syntax: :scss
))
end
private
def engine_from_path(name, dir, options)
full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
return unless full_filename && File.readable?(full_filename)
Sass::Engine.for_file(full_filename, options)
end
end
+2 -2
View File
@@ -35,10 +35,10 @@ task 'assets:precompile:before' do
def evaluate(context, locals, &block)
::Sprockets.cache_compiled("sass", data) do
# HACK, SASS compiler will degrade to aweful perf with huge files
# Bypass if larger than 500kb, ensure assets are minified prior
# Bypass if larger than 200kb, ensure assets are minified prior
if context.pathname &&
context.pathname.to_s =~ /.css$/ &&
data.length > 500.kilobytes
data.length > 200.kilobytes
puts "Skipped minifying #{context.pathname} cause it is larger than 200KB, minify in source control or avoid large CSS files"
data
else