-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
40 lines (37 loc) · 1.06 KB
/
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
var cssnext = require("cssnext")
var assign = require("object-assign")
var loaderUtils = require("loader-utils")
function defaultOptions(context, map){
var options = {}
options.from = loaderUtils.getRemainingRequest(context)
options.to = loaderUtils.getRemainingRequest(context)
if (context.sourceMap) {
options.map = {
inline: false,
annotation: false,
prev: map
}
}
options.compress = context.minimize
return options
}
function cssnextLoader(contents, map){
this.cacheable()
var options = assign({}, defaultOptions(this, map), this.options.cssnext)
options.features = assign({}, this.options.cssnext ? this.options.cssnext.features : null)
options.import = assign({}, options.import || null)
options.import.onImport = function(files){
files.forEach(this.addDependency)
}.bind(this)
try {
var result = cssnext(contents, options)
if (result.css) {
this.callback(null, result.css, result.map)
} else {
return result
}
} catch(err) {
this.emitError(err)
}
}
module.exports = cssnextLoader