Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.js
More file actions
Latest commit
62 lines (52 loc) · 1.42 KB
/
Copy pathindex.js
File metadata and controls
62 lines (52 loc) · 1.42 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
constdefined=require('defined')
constpostcss=require('postcss')
constextend=require('xtend')
constresolve=require('resolve')
constpostcssrc=require('postcss-load-config')
module.exports=transform
functiontransform(filename,source,options,done){
options=defined(options,{})
constbasedir=options.basedir
constplugins=defined(options.plugins,[])
.map(plugin=>{
if(typeofplugin==='string'){
plugin=[plugin]
}
return{
path: resolve.sync(plugin[0],{ basedir }),
options: plugin[1]
}
})
.map(plugin=>require(plugin.path)(plugin.options))
constctx=extend({
sourcemap: true,
from: filename,
messages: {
browser: true,
console: false
}
},options)
deletectx.plugins
postcssrc(ctx,basedir).then(compile,function(){
returncompile({options: ctx})
}).then(function(result){
done(null,result)
},done)
functioncompile(config){
returnpostcss(plugins.concat(config.plugins).filter(Boolean))
.process(source,config.options)
.then(function(result){
// Collect imported files for watchify
constfiles=[filename]
result.messages.forEach(function(msg){
if(msg.type==='dependency'){
files.push(msg.file)
}
})
return{
css: result.css,
files: files
}
})
}
}