Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Task to compile Less #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ require "rubygems"
require 'rake'
require 'yaml'
require 'time'
require 'less'

SOURCE = "."
LESS = File.join(SOURCE, "assets", "themes", "twitter") # set theme here
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions welcome for dealing with this. Read in _config.yml, perhaps? It seems a lot of work just to get a variable. It's a pain because the theme is jekyll-land, whereas the Rakefile is JB-land.

CONFIG = {
'version' => "0.2.9",
'themes' => File.join(SOURCE, "_includes", "themes"),
'layouts' => File.join(SOURCE, "_layouts"),
'posts' => File.join(SOURCE, "_posts"),
'post_ext' => "md",
'theme_package_version' => "0.1.0"
'theme_package_version' => "0.1.0",
'less' => File.join(LESS, "less"),
'css' => File.join(LESS, "css"),
'input' => "style.less",
'output' => "style.css"
}

# Path configuration helper
Expand Down Expand Up @@ -98,6 +104,23 @@ task :preview do
system "jekyll --auto --server"
end # task :preview

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

# Public: Alias - Maintains backwards compatability for theme switching.
task :switch_theme => "theme:switch"

Expand Down