forked from duojs/sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (28 loc) · 827 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
'use strict';
var assign = require('object-assign');
var debug = require('debug')('duosass');
var parseImport = require('parse-import');
var sass = require('node-sass').renderSync;
module.exports = function (opts) {
opts = opts || {};
return function (file) {
if (file.type !== 'scss' && file.type !== 'sass') {
return;
}
debug('compiling %s to css', file.id);
var imports = parseImport(file.src).filter(function (imprt) {
return imprt.path.indexOf('.') !== 0;
}).map(function (imprt) {
imprt.rule = imprt.rule + ';';
file.src = file.src.replace(imprt.rule, '');
return imprt.rule;
});
var result = sass(assign({
data: file.src,
includePaths: [file.root],
indentedSyntax: file.type === 'sass'
}, opts));
file.src = imports.join('\n') + result.css;
file.type = 'css';
};
};