Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 1b2659a

Browse files
Darius Tallyyx990803
Darius Tall
authored andcommitted
Add the ability to specify other postcss options (#99)
* Add the ability to specify other postcss options * Fixed usage of postcss
1 parent 1b05390 commit 1b2659a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/style-rewriter.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ module.exports = function (id, css, scoped, options) {
4545
if (val) {
4646
return Promise.resolve(val)
4747
} else {
48-
var plugins = options.postcss
49-
? options.postcss.slice()
50-
: []
48+
var plugins = []
49+
var opts = {}
50+
51+
if (options.postcss instanceof Array) {
52+
plugins = options.postcss.slice()
53+
} else if (options.postcss instanceof Object) {
54+
plugins = options.postcss.plugins || []
55+
opts = options.postcss.options
56+
}
57+
5158
// scoped css rewrite
5259
if (scoped) {
5360
plugins.push(addId)
@@ -60,10 +67,11 @@ module.exports = function (id, css, scoped, options) {
6067
}
6168
currentId = id
6269
return postcss(plugins)
63-
.process(css)
70+
.process(css, opts)
6471
.then(function (res) {
6572
cache.set(key, res.css)
6673
return res.css
6774
})
6875
}
6976
}
77+

0 commit comments

Comments
 (0)