-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
45 lines (34 loc) · 978 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var stss = require('stss');
var through2 = require('through2');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var path = require('path');
module.exports = function () {
function transform(file, enc, next) {
var self = this;
if (file.isNull()) {
this.push(file);
return next();
}
if (file.isStream()) {
this.emit('error', new PluginError('gulp-stss', 'Streaming not supported'));
return next();
}
var stssContent = file.contents.toString('utf8');
stss.renderSync({
data: stssContent,
includePaths: [path.dirname(file.path)],
success: function (tss) {
file.contents = new Buffer(tss);
file.path = gutil.replaceExtension(file.path, '.tss');
self.push(file);
next();
},
error: function (err) {
self.emit('error', new PluginError('gulp-stss', err));
next();
}
});
}
return through2.obj(transform);
};