Created
December 8, 2012 07:59
-
-
Save BrianHicks/4239179 to your computer and use it in GitHub Desktop.
Improved Compass Rendering for Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zurb-foundation' | |
# Require any additional compass plugins here. | |
# Set this to the root of your project when deployed: | |
http_path = "/" | |
css_dir = "_site/static/css" | |
sass_dir = "_sass" | |
images_dir = "static/images" | |
javascripts_dir = "static/js" | |
fonts_dir = "static/fonts" | |
# You can select your preferred output style here (can be overridden via the command line): | |
# output_style = :expanded or :nested or :compact or :compressed | |
# To enable relative paths to assets via compass helper functions. Uncomment: | |
# relative_assets = true | |
# To disable debugging comments that display the original location of your selectors. Uncomment: | |
# line_comments = false | |
# If you prefer the indented syntax, you might want to regenerate this | |
# project again passing --syntax sass, or you can uncomment this: | |
# preferred_syntax = :sass | |
# and then run: | |
# sass-convert -R --from scss --to sass _sass scss && rm -rf sass && mv scss sass | |
preferred_syntax = :scss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Jekyll Generator for SCSS / Compass | |
# | |
# (File paths in this description relative to jekyll project root directory) | |
# Config file placed in ./_compass.rb | |
# | |
# Several things to note: | |
# - css_dir should be in _site | |
# - sass_dir should be something like _sass | |
# | |
# But everything else should Just Work (tm) | |
# | |
require 'sass/plugin' | |
require 'compass' | |
module Jekyll | |
class CompassGenerator < Generator | |
safe true | |
class SassFile < StaticFile | |
def initialize(site, base, dir, name, compiler) | |
@site = site | |
@base = base | |
@dir = dir | |
@name = name | |
@compiler = compiler | |
end | |
def write(path) | |
from = File.join(@base, @dir, @name) | |
to = @compiler.corresponding_css_file from | |
# we don't need to do any more work if we don't need to render | |
return false if not @compiler.should_compile?(from, to) | |
@@mtimes[path] = mtime | |
FileUtils.mkdir_p(File.dirname(to)) | |
@compiler.compile from, to | |
true | |
end | |
end | |
def generate(site) | |
Compass.add_project_configuration(*Compass.configuration_for('_compass.rb')) | |
Compass.compiler.sass_files.each do |fname| | |
path, name = File.split fname | |
path = path.sub site.source + '/', '' | |
site.static_files << SassFile.new(site, site.source, path, name, Compass.compiler) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment