initial commit
This commit is contained in:
commit
d3fcd7f10c
3159 files changed
+349702
No files matched your search
+62
@@ -0,0 +1,62 @@
|
||||
var map = require('map-stream')
|
||||
, sass = require('node-sass')
|
||||
, path = require('path')
|
||||
, gutil = require('gulp-util')
|
||||
, ext = gutil.replaceExtension
|
||||
;
|
||||
|
||||
module.exports = function (options) {
|
||||
var opts = options ? options : {};
|
||||
|
||||
function nodeSass (file, cb) {
|
||||
var fileDir = path.dirname(file.path);
|
||||
var addedLocalDirPath = false;
|
||||
|
||||
if (file.isNull()) {
|
||||
return cb(null, file);
|
||||
}
|
||||
if (path.basename(file.path).indexOf('_') === 0) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
opts.data = file.contents.toString();
|
||||
|
||||
if (opts.includePaths && Array.isArray(opts.includePaths)) {
|
||||
if (opts.includePaths.indexOf(fileDir) === -1) {
|
||||
opts.includePaths.push(fileDir);
|
||||
addedLocalDirPath = true;
|
||||
}
|
||||
} else {
|
||||
opts.includePaths = [fileDir];
|
||||
}
|
||||
|
||||
opts.success = function (css) {
|
||||
if (typeof opts.onSuccess === 'function') opts.onSuccess(css);
|
||||
|
||||
file.path = ext(file.path, '.css');
|
||||
file.contents = new Buffer(css);
|
||||
cb(null, file);
|
||||
};
|
||||
|
||||
opts.error = function (err) {
|
||||
if (opts.errLogToConsole) {
|
||||
gutil.log('[gulp-sass] ' + err);
|
||||
return cb();
|
||||
}
|
||||
|
||||
if (typeof opts.onError === 'function') {
|
||||
opts.onError(err);
|
||||
return cb();
|
||||
}
|
||||
|
||||
return cb(new gutil.PluginError('gulp-sass', err));
|
||||
};
|
||||
|
||||
sass.render(opts);
|
||||
|
||||
if (addedLocalDirPath) opts.includePaths.pop();
|
||||
|
||||
}
|
||||
|
||||
return map(nodeSass);
|
||||
};
|
||||
Reference in new issue
Block a user