Browse files

Swap YUI Compressor for a pure-Ruby CSS minifier.

  • Loading branch information...
1 parent 7f7c199 commit 2f79107431bb7ae7d2f1c459ec5d256d721c1f96 @beastaugh committed Jan 23, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 Rakefile
View
11 Rakefile
@@ -1,7 +1,7 @@
require 'pathname'
require 'packr'
-require 'yui/compressor'
+require 'sass'
desc "Create a zip file of the lastest release"
task :build do
@@ -43,11 +43,10 @@ namespace :minify do
task :css do
main = "style.dev.css"
files = Dir.glob("library/css/*.dev.css") << main
- compressor = YUI::CssCompressor.new
files.each do |file|
code = File.read(file)
- compressed = compressor.compress(code)
+ compressed = minify_css(code, file)
if file == main
header = code.match(/\/\*.+?\*\//m)[0]
@@ -67,3 +66,9 @@ def theme_version(stylesheet)
prefix = "Version: "
lines.select {|line| line =~ /^#{prefix}/ }.first.sub(prefix, "").strip
end
+
+def minify_css(str, filename)
+ root_node = ::Sass::SCSS::CssParser.new(str, filename).parse
+ root_node.options = {:style => :compressed}
+ root_node.render.strip
+end

0 comments on commit 2f79107

Please sign in to comment.