Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (32 sloc) 1.045 kb
require 'packr'
require 'yui/compressor'
desc "Compress JavaScript and CSS files"
task :minify => [:"minify:js", :"minify:css"]
namespace :minify do
desc "Compress JavaScript files"
task :js do
Dir.glob("app/js/*.dev.js").each do |file|
options = {:shrink_vars => true, :private => true}
code = File.read(file)
compressed = Packr.pack(code, options)
File.open(file.sub(/\.dev.js$/, ".js"), "w") { |f| f.write(compressed) }
end
end
desc "Compress CSS files"
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)
if file == main
header = code.match(/\/\*.+?\*\//m)[0]
output = header + "\n" + compressed
else
output = compressed
end
File.open(file.sub(/\.dev\.css/, ".css"), "w") { |f| f.write(output) }
end
end
end
Jump to Line
Something went wrong with that request. Please try again.