From 1b2659a1f87b8a8878135477641e00fd45ee42c2 Mon Sep 17 00:00:00 2001 From: Darius Tall Date: Fri, 24 Jun 2016 10:25:08 -0400 Subject: [PATCH] Add the ability to specify other postcss options (#99) * Add the ability to specify other postcss options * Fixed usage of postcss --- lib/style-rewriter.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/style-rewriter.js b/lib/style-rewriter.js index 9881524..c631857 100644 --- a/lib/style-rewriter.js +++ b/lib/style-rewriter.js @@ -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) @@ -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 }) } } +