Skip to content

Instantly share code, notes, and snippets.

@peregrinator
Created November 9, 2009 18:09
Show Gist options
  • Save peregrinator/230143 to your computer and use it in GitHub Desktop.
Save peregrinator/230143 to your computer and use it in GitHub Desktop.
Rake task to build jekyll site when using Less CSS
# Rakefile
require 'rake'
load 'tasks/site.rake'
# tasks/site.rake
namespace :site do
desc "Build css files from .less files"
task :less do
less_directory = 'less'
css_directory = 'css'
Dir.glob(less_directory + '/*.less').each do |file|
if File.file?(file)
file_name = file.split('/').last.split('.').first
puts "* Creating css file for less file named #{file_name} \n"
`lessc #{less_directory}/#{file_name}.less #{css_directory}/#{file_name}.css`
end
end
end
desc "Build static files from jekyll files"
task :jekyll do
puts "* Building static files from jekyll files"
`jekyll`
end
desc "Build site (less and jekyll)"
task :build do
puts "[START] Building site [START]"
Rake::Task["site:less"].invoke
Rake::Task["site:jekyll"].invoke
puts "[END] Building site [END]"
end
end
@matthodan
Copy link

Not sure if this would be overkill, but for a larger site you might want to use an asset pipeline like Jekyll Asset Pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment