From 6850af11c57f70df004f02ba77fe41675539f136 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 2 Feb 2023 23:25:33 +0000 Subject: [PATCH] feat: normalise postcss options to reduce breaking change --- packages/webpack/src/utils/postcss.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/webpack/src/utils/postcss.js b/packages/webpack/src/utils/postcss.js index 7ad2fdfbe1..a6c77dfd44 100644 --- a/packages/webpack/src/utils/postcss.js +++ b/packages/webpack/src/utils/postcss.js @@ -194,6 +194,16 @@ export default class PostcssConfig { // Apply default plugins if (isPureObject(postcssOptions)) { + const postcssLoaderOptions = this.postcssLoaderOptions + if (postcssLoaderOptions.plugins && !postcssOptions.plugins) { + postcssOptions.plugins = postcssLoaderOptions.plugins + delete postcssLoaderOptions.plugins + } + if (postcssLoaderOptions.order && !postcssOptions.order) { + postcssOptions.order = postcssLoaderOptions.order + delete postcssLoaderOptions.order + } + if (Array.isArray(postcssOptions.plugins)) { defaults(postcssOptions, this.defaultPostcssOptions) } else { @@ -203,7 +213,6 @@ export default class PostcssConfig { } delete postcssOptions.order - const postcssLoaderOptions = this.postcssLoaderOptions delete postcssLoaderOptions.preset return {