Skip to content

Instantly share code, notes, and snippets.

@mattraykowski
Created January 12, 2016 16:02
Show Gist options
  • Save mattraykowski/94a212a30dc54db12c33 to your computer and use it in GitHub Desktop.
Save mattraykowski/94a212a30dc54db12c33 to your computer and use it in GitHub Desktop.
wintersmith-libsass fix for node 3.0.0 style callbacks.
fs = require 'fs'
sass = require 'node-sass'
ccss = require 'clean-css'
module.exports = (env, callback) ->
class NodeSassPlugin extends env.ContentPlugin
constructor: (@filepath) ->
getFilename: ->
@filepath.relative.replace /scss$/, 'css'
getView: -> (env, locals, contents, templates, callback) ->
config = env.config['node-sass'] or {}
includePaths = config.includePaths or []
includePaths.push env.config.templates
includePaths.push env.config.contents
sass.render
file: @filepath.full
includePaths: includePaths,
(err, css) ->
if err
callback new Error err
if config.minify isnt false
css = new ccss(env.config['clean-css']).minify(css.css)
callback null, new Buffer css.styles
else
callback null, new Buffer css.css
NodeSassPlugin.fromFile = (filepath, callback) ->
plugin = new NodeSassPlugin filepath
callback null, plugin
env.registerContentPlugin 'styles', '**/[^_]*.scss', NodeSassPlugin
callback()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment