forked from stealjs/steal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathless.js
41 lines (33 loc) · 992 Bytes
/
less.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 css = require("$css");
var lessEngine = require("less");
exports.instantiate = css.instantiate;
var options = steal.config('lessOptions') || {};
// default optimization value.
options.optimization |= lessEngine.optimization;
exports.translate = function(load) {
var pathParts = (load.address+'').split('/');
pathParts[pathParts.length - 1] = ''; // Remove filename
var paths = [];
if (typeof window !== 'undefined') {
pathParts = (load.address+'').split('/');
pathParts[pathParts.length - 1] = ''; // Remove filename
paths = [pathParts.join('/')];
}
return new Promise(function(resolve, reject){
options.filename = load.address;
options.paths = [pathParts.join('/')];
var Parser = lessEngine.Parser;
new Parser(options).parse(load.source, function (e, root) {
if(e){
reject(e);
} else {
resolve(root.toCSS(options));
}
});
});
};
exports.tildeModules = [
/@import ['"](~\/.+)['"]/g,
/url\(['"](~\/.+)['"]/g
];
exports.buildType = "css";