-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (42 loc) · 1 KB
/
index.js
File metadata and controls
46 lines (42 loc) · 1 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
/* eslint no-debugger: 0 */
"use strict";
const resolveId = require('postcss-import/lib/resolve-id.js');
const AtImport = require('postcss-import');
const resolve = require('import-sub');
function sub(options) {
/**
* Support simple mode of rules definition
*/
let rules;
if (options instanceof Array) {
rules = options;
options = {};
} else {
rules = options.sub;
delete options.sub;
}
options.originalResolve = resolveId;
/**
* Define real options
*/
return Object.assign({}, options, {
resolve: function(id, base, importOptions) {
return resolve(rules, Object.assign(
{},
options,
{
base: base,
request: id,
importOptions: importOptions || {},
}
));
}
});
}
module.exports = function substitute(options) {
return AtImport(sub(options));
}
module.exports.sub = sub;
module.exports.process = AtImport.process;
module.exports.postcss = AtImport.postcss;
module.exports.AtImport = AtImport;