diff --git a/lib/style-rewriter.js b/lib/style-rewriter.js index 23064b00b..cce1e4867 100644 --- a/lib/style-rewriter.js +++ b/lib/style-rewriter.js @@ -3,8 +3,7 @@ var selectorParser = require('postcss-selector-parser') var loaderUtils = require('loader-utils') var assign = require('object-assign') -var currentId -var addId = postcss.plugin('add-id', function () { +var addId = postcss.plugin('add-id', function (opts) { return function (root) { root.each(function rewriteSelector (node) { if (!node.selector) { @@ -21,7 +20,7 @@ var addId = postcss.plugin('add-id', function () { if (n.type !== 'pseudo') node = n }) selector.insertAfter(node, selectorParser.attribute({ - attribute: currentId + attribute: opts.id })) }) }).process(node.selector).result @@ -46,7 +45,7 @@ module.exports = function (css, map) { // scoped css if (query.scoped) { - plugins.push(addId) + plugins.push(addId({ id: query.id })) } // autoprefixer @@ -82,7 +81,6 @@ module.exports = function (css, map) { } } - currentId = query.id postcss(plugins) .process(css, opts) .then(function (result) {