Skip to content

Commit 0ba6c34

Browse files
authored
fix: support async PostCSS plugins in postcss-if-function (#137)
* fix: async error * Create six-monkeys-draw.md
1 parent df93d9b commit 0ba6c34

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.changeset/six-monkeys-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"postcss-if-function": patch
3+
---
4+
5+
fix: support `async` PostCSS plugins in `postcss-if-function`

packages/postcss-if-function/src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function postcssIfFunction(options = {}) {
5959

6060
return {
6161
postcssPlugin: PLUGIN_NAME,
62-
Once(root, { result }) {
62+
async Once(root, { result }) {
6363
// Collect all CSS text first
6464
const cssText = root.toString();
6565

@@ -85,13 +85,14 @@ function postcssIfFunction(options = {}) {
8585
// double parsing overhead identified by static analysis tools.
8686

8787
try {
88-
const transformedRoot = result.processor.process(
88+
const processed = await result.processor.process(
8989
transformed.nativeCSS,
9090
{
9191
from: undefined,
9292
parser: result.processor.parser
9393
}
94-
).root;
94+
);
95+
const transformedRoot = processed.root;
9596

9697
// Clone nodes to preserve original formatting and avoid reference issues
9798
transformedRoot.each((node) => {

0 commit comments

Comments
 (0)