cssrubynanoc

Nanoc filter for SCSS


I'm writing a site using nanoc and ruby, and I want to use SCSS. But I'm having a bit of an issue. No matter what I try, I cannot get my SCSS file to convert and output as compiled CSS. It either throws an error or comes through as exactly the same file type. My Ruby rules file and directory structure is below, please help!

#!/usr/bin/env ruby

compile '/**/*.html' do
  layout '/default.*'
end

# This is an example rule that matches Markdown (.md) files, and filters them
# using the :kramdown filter. It is commented out by default, because kramdown
# is not bundled with Nanoc or Ruby.
#
#compile '/**/*.md' do
#  filter :kramdown
#  layout '/default.*'
#end

route '/**/*.{html,md}' do
  if item.identifier =~ '/index.*'
    '/index.html'
  else
    item.identifier.without_ext + '/index.html'
  end
end

compile '/assets/SCSS/' do
  filter :scss => :css
  write @item.identifier.without_ext + '.css'
 end

compile '/assets/images/*' do
  write item.identifier.to_s
end

compile '/**/*' do
  write item.identifier.to_s
end

layout '/**/*', :erb

Here is my directory structure:

root
|
|\_content
|  |
|   \_assets
|     |
|      \_test.scss
\_public
  |
   \_assets
     |
      \_test.scss <-------- This should be compiled CSS

Solution

  • I found a utility called Compass that gives you filter options for SCSS.