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

Commit

Permalink
Add the ability to specify other postcss options (#99)
Browse files Browse the repository at this point in the history
* Add the ability to specify other postcss options

* Fixed usage of postcss
  • Loading branch information
Darius Tall authored and yyx990803 committed Jun 24, 2016
1 parent 1b05390 commit 1b2659a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ module.exports = function (id, css, scoped, options) {
if (val) {
return Promise.resolve(val)
} else {
var plugins = options.postcss
? options.postcss.slice()
: []
var plugins = []
var opts = {}

if (options.postcss instanceof Array) {
plugins = options.postcss.slice()
} else if (options.postcss instanceof Object) {
plugins = options.postcss.plugins || []
opts = options.postcss.options
}

// scoped css rewrite
if (scoped) {
plugins.push(addId)
Expand All @@ -60,10 +67,11 @@ module.exports = function (id, css, scoped, options) {
}
currentId = id
return postcss(plugins)
.process(css)
.process(css, opts)
.then(function (res) {
cache.set(key, res.css)
return res.css
})
}
}

0 comments on commit 1b2659a

Please sign in to comment.