Skip to content

Commit 8a0189d

Browse files
committed
refactor: added default export to PostCSS plugin
1 parent fc0f596 commit 8a0189d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/postcss-if-function/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,27 @@ npm install postcss-if-function postcss
1616

1717
## Usage
1818

19-
### Basic Usage
19+
### PostCSS CLI
20+
21+
```bash
22+
# Transform CSS using PostCSS CLI
23+
npx postcss input.css --output output.css --use postcss-if-function
24+
25+
# With custom PostCSS config file
26+
npx postcss input.css --output output.css --config postcss.config.js
27+
```
28+
29+
### Basic Programmatic Usage
2030

2131
```js
32+
// Named export (recommended)
2233
import postcss from "postcss";
2334
import { postcssIfFunction } from "postcss-if-function";
2435

36+
// Or default export (for compatibility)
37+
import postcss from "postcss";
38+
import postcssIfFunction from "postcss-if-function";
39+
2540
const css = `
2641
.example {
2742
color: if(media(max-width: 768px): blue; else: red);
@@ -69,6 +84,21 @@ const result = await postcss([
6984
]).process(css, { from: undefined });
7085
```
7186

87+
### With PostCSS Config File
88+
89+
```js
90+
// postcss.config.js
91+
import { postcssIfFunction } from "postcss-if-function";
92+
93+
export default {
94+
plugins: [
95+
postcssIfFunction({
96+
logTransformations: process.env.NODE_ENV === "development"
97+
})
98+
]
99+
};
100+
```
101+
72102
### With Popular PostCSS Tools
73103

74104
#### Vite

packages/postcss-if-function/src/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ export function postcssIfFunction(
3333
export namespace postcssIfFunction {
3434
const postcss: boolean;
3535
}
36+
37+
export default postcssIfFunction;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,4 @@ function postcssIfFunction(options = {}) {
119119
postcssIfFunction.postcss = true;
120120

121121
export { postcssIfFunction };
122+
export default postcssIfFunction;

0 commit comments

Comments
 (0)