diff --git a/index.js b/index.js index 924f53c..0763f2a 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ class POSTCSSInOut { this.options = options; } - process(children, callback) { + processPostBuild(children, callback) { const collection = Object.keys(children).map((j) => { let child = children[j]; if (typeof child === 'object') { @@ -68,21 +68,13 @@ class POSTCSSInOut { compilation.hooks.processAssets.tap( { name: 'POSTCSSInOut', - stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONS, // see below for more stages - additionalAssets: true + stage: compilation.PROCESS_ASSETS_STAGE_ADDITIONS // see below for more stages }, (assets) => { Object.keys(assets).map((i) => { if (i.indexOf('.css') !== -1) { - this.process(assets[i]._source._children, (results) => { - assets[i]._source._children = []; - - compilation.updateAsset( - i, - new sources.RawSource( - results - ) - ); + this.processPostBuild(assets[i]._source._children, (results) => { + compilation.updateAsset(i, new sources.RawSource(results)); }); } }); @@ -95,4 +87,4 @@ class POSTCSSInOut { } } -module.exports = POSTCSSInOut; +module.exports = POSTCSSInOut; \ No newline at end of file diff --git a/package.json b/package.json index 690f523..4a767f9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "postcss global variables", "postcss global features" ], - "version": "1.5.1", + "version": "1.5.2", "description": "Plugin to add pre & post build hooks for global POSTCSS features", "repository": "drolsen/postcss-in-out", "bugs": { @@ -30,8 +30,8 @@ "mini-css-extract-plugin": "^1.3.2", "postcss-import": "^13.0.0", "postcss-nested": "^5.0.3", - "webpack": "^5.10.0", - "webpack-cli": "^4.2.0" + "webpack": "^5.64.0", + "webpack-cli": "^4.9.1" }, "dependencies": { "postcss": "^8.2.1", diff --git a/test/test.plugins.js b/test/test.plugins.js index 37bbd11..a354c87 100644 --- a/test/test.plugins.js +++ b/test/test.plugins.js @@ -99,8 +99,8 @@ const media = (options = {}) => { if (key === variable) { rule.params = queries[key]; - // gather meida queries inners - rule.walkRules(innerRules => { + // gather media queries inners + root.walkRules(innerRules => { let stringSelector = ` ${innerRules.selector} {\n`; innerRules.walkDecls(innerDecl => { stringSelector += ` ${innerDecl.prop}: ${innerDecl.value};\n`;