Skip to content

Instantly share code, notes, and snippets.

@pfig pfig/Rakefile
Created Mar 3, 2012

Embed
What would you like to do?
Rake task to compile Less to CSS
require 'rubygems'
require 'less'
require 'rake'
SOURCE = "."
LESS = File.join( SOURCE, "path", "to", "less", "files" )
CONFIG = {
'less' => File.join( LESS, "less" ),
'css' => File.join( LESS, "css" ),
'input' => "style.less",
'output' => "style.css"
}
desc "Compile Less"
task :lessc do
less = CONFIG['less']
input = File.join( less, CONFIG['input'] )
output = File.join( CONFIG['css'], CONFIG['output'] )
source = File.open( input, "r" ).read
parser = Less::Parser.new( :paths => [less] )
tree = parser.parse( source )
File.open( output, "w+" ) do |f|
f.puts tree.to_css( :compress => true )
end
end # task :lessc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.