Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#
# Jekyll Generator for SCSS
#
# (File paths in this description relative to jekyll project root directory)
# Place this file in ./_plugins
# Place .scss files in ./_scss
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
# Config file placed in ./_sass/config.rb
#
require 'sass'
require 'pathname'
require 'compass'
require 'compass/exec'
module Jekyll
class CompassGenerator < Generator
safe true
def generate(site)
Dir.chdir File.expand_path('../_sass', File.dirname(__FILE__)) do
Compass::Exec::SubCommandUI.new(%w(compile)).run!
end
end
end
end
Owner

davidpots commented Jun 24, 2013

This is via @parkr's gist found here: https://gist.github.com/parkr/2874934

Also, I had to make my Compass config.rb look like this to make it work:

http_path = "/"
sass_dir = "./"
css_dir = "../css"
images_dir = "../img"
javascripts_dir = "../js"
relative_assets = true

drewish commented Aug 25, 2013

The comment mentions # Place .scss files in ./_scss but the code looks in _sass

+1, @davidpots line 22 should be

Dir.chdir File.expand_path('../_sass', File.dirname(__FILE__)) do

mgudapak commented Jan 2, 2014

Hi David

I am using your plugin with the latest Jekyll version but the css never gets generated inside the "_site" folder on running 'jekyll serve --watch'

Here's how my config.rb looks like

http_path = "/"
sass_dir = "./"
css_dir = "../_site/css"
images_dir = "../_site/img"
javascripts_dir = "../_site/js"
output_style = :expanded
relative_assets = true

My jekyll directories are setup just like you mentioned. Is it possible that compass generates the css files in the said directory but that is followed by jekyll which erases and recreates the '_site' directory so the css files are getting deleted?

if I set the css_dir = "../css" things are okay but the issue is the stylesheets get compiled outside of the '_site' directory and I'd like it inside of it.

Am i doing something silly here or is it the expected behavior that you cannot generate the css inside '_site'.

Thanks for your help.
Regards
Mahesh

Hi there. Thanks for the great tutorial over at http://davidpots.com/blog/jekyll-github-pages-compass/.

I was wondering if you could explain how to generate the site into it's own separate folder so I can host it as a static site with a host other than github?

Any help would be much appreciated!

@ThomasHoadley The site generates into _site. You can point your domain name to your _site folder in jekyll. On a second thought of this whole hack, why not just use jekyll-assets ?

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