Skip to content

Commit

Permalink
feat: support postcss-import-url if configured (#401)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
wesleyboar authored Sep 25, 2024
1 parent 7facd72 commit 34ffb0d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/bin/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 34ffb0d

Please sign in to comment.