3.x - 4.x.js
2.08 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Generated by CoffeeScript 1.12.1
(function() {
var Adapter, SCSS, W, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
path = require('path');
SCSS = (function(superClass) {
extend(SCSS, superClass);
function SCSS() {
return SCSS.__super__.constructor.apply(this, arguments);
}
SCSS.prototype.name = 'scss';
SCSS.prototype.extensions = ['scss', 'sass'];
SCSS.prototype.output = 'css';
SCSS.prototype.supportedEngines = ['node-sass'];
SCSS.prototype._render = function(str, options) {
var deferred;
deferred = W.defer();
if (options.sourcemap === true) {
options.sourceMap = true;
options.outFile = options.filename.replace('.scss', '.css');
options.omitSourceMapUrl = true;
options.sourceMapContents = true;
}
options.file = options.filename;
options.data = str;
this.engine.render(options, function(err, res) {
var basePath, data;
if (err) {
return deferred.reject(err);
}
data = {
result: String(res.css),
imports: res.stats.includedFiles,
meta: {
entry: res.stats.entry,
start: res.stats.start,
end: res.stats.end,
duration: res.stats.duration
}
};
if (res.map) {
data.sourcemap = JSON.parse(res.map.toString('utf8'));
basePath = path.dirname(options.filename);
data.sourcemap.sources = data.sourcemap.sources.map(function(relativePath) {
return path.join(basePath, relativePath);
});
}
return deferred.resolve(data);
});
return deferred.promise;
};
return SCSS;
})(Adapter);
module.exports = SCSS;
}).call(this);