From 34ffb0d640decc97057ce8f85a0c05d5e403a45b Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:24:24 -0500 Subject: [PATCH] feat: support postcss-import-url if configured (#401) * feat: support postcss-import-url if configured (`postcss-import-url` should be at top of config, like `postcss-import`) * docs: tweak a comment * chore: remove new unused function * fix: support postcss-import-url if configured - Search `plugins` object value for `postcss-import-url`, not root. - Test for `postcss-import-url` key with basic older code. --- src/bin/config.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bin/config.js b/src/bin/config.js index 3448f9afb..d6c3e0365 100755 --- a/src/bin/config.js +++ b/src/bin/config.js @@ -26,9 +26,31 @@ function config(customConfigFiles = [], cssVersion) { // Initialize final config file emptyOrCreateFile(NEW_CONFIG_FILE); + // Manipulate final config + configFiles.forEach((nextFile) => { + const testJson = getConfigObject(nextFile); + + // The 'postcss-import-url' should be moved to front of config + if (testJson.plugins && 'postcss-import-url' in testJson.plugins) { + + configObjects.unshift({ + 'plugins': { + 'postcss-import-url': testJson.plugins['postcss-import-url'] + } + }); + } + }); + // Merge configs in order configFiles.forEach((nextFile) => { newJson = getConfigObject(nextFile); + + // The 'postcss-import-url' would have been moved to front of config + if (newJson.plugins && 'postcss-import-url' in newJson.plugins) { + + delete newJson.plugins['postcss-import-url']; + } + configObjects.push(newJson); }); const mergedJson = merge(...configObjects);