-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathindex.ts
More file actions
30 lines (25 loc) · 696 Bytes
/
index.ts
File metadata and controls
30 lines (25 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { PluginCreator } from 'postcss';
import { parseStyles } from './lib/parse-styles';
import { applyConditions } from './lib/apply-conditions';
import { applyStyles } from './lib/apply-styles';
import { postProcess } from './lib/post-process';
const creator: PluginCreator<never> = () => {
return {
postcssPlugin: 'postcss-bundler',
async Once(styles, { result, atRule, root, postcss }): Promise<void> {
const bundle = await parseStyles(
result,
styles,
null,
[],
[],
postcss,
);
postProcess(bundle, atRule, root);
applyConditions(bundle, atRule);
applyStyles(bundle, styles);
},
};
};
creator.postcss = true;
export default creator;