Created
January 12, 2016 16:02
-
-
Save mattraykowski/94a212a30dc54db12c33 to your computer and use it in GitHub Desktop.
wintersmith-libsass fix for node 3.0.0 style callbacks.
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
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