forked from vuejs/rollup-plugin-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.js
27 lines (23 loc) · 864 Bytes
/
postcss.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
import postcssrc from 'postcss-load-config'
/* eslint-disable complexity */
export default async function (postcssOpt) {
let options = {}
let plugins = []
if (typeof postcssOpt === 'function') {
plugins = postcssOpt.call(this)
} else if (Array.isArray(postcssOpt)) {
plugins = postcssOpt
} else if (typeof postcssOpt === 'object') {
plugins = (typeof postcssOpt.plugins === 'function') ? postcssOpt.plugins.call(this) : postcssOpt.plugins || []
options = postcssOpt.options || {}
}
return postcssrc().then((config) => {
if (config.plugins) {
plugins = plugins.concat(config.plugins)
}
if (config.options) {
options = Object.assign(options, config.options)
}
return {plugins, options}
}).catch(() => { return {plugins, options} })
}