1 | /**
|
2 | * PostCSS Plugin for PurgeCSS
|
3 | *
|
4 | * Most bundlers and frameworks to build websites are using PostCSS.
|
5 | * The easiest way to configure PurgeCSS is with its PostCSS plugin.
|
6 | *
|
7 | * @packageDocumentation
|
8 | */
|
9 |
|
10 | import * as postcss from 'postcss';
|
11 |
|
12 | /**
|
13 | * @public
|
14 | */
|
15 | export declare type ComplexSafelist = {
|
16 | standard?: StringRegExpArray;
|
17 | /**
|
18 | * You can safelist selectors and their children based on a regular
|
19 | * expression with `safelist.deep`
|
20 | *
|
21 | * @example
|
22 | *
|
23 | * ```ts
|
24 | * const purgecss = await new PurgeCSS().purge({
|
25 | * content: [],
|
26 | * css: [],
|
27 | * safelist: {
|
28 | * deep: [/red$/]
|
29 | * }
|
30 | * })
|
31 | * ```
|
32 | *
|
33 | * In this example, selectors such as `.bg-red .child-of-bg` will be left
|
34 | * in the final CSS, even if `child-of-bg` is not found.
|
35 | *
|
36 | */
|
37 | deep?: RegExp[];
|
38 | greedy?: RegExp[];
|
39 | variables?: StringRegExpArray;
|
40 | keyframes?: StringRegExpArray;
|
41 | };
|
42 |
|
43 | /**
|
44 | * @public
|
45 | */
|
46 | export declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
|
47 |
|
48 | /**
|
49 | * @public
|
50 | */
|
51 | export declare type ExtractorResult = ExtractorResultDetailed | string[];
|
52 |
|
53 | /**
|
54 | * @public
|
55 | */
|
56 | export declare interface ExtractorResultDetailed {
|
57 | attributes: {
|
58 | names: string[];
|
59 | values: string[];
|
60 | };
|
61 | classes: string[];
|
62 | ids: string[];
|
63 | tags: string[];
|
64 | undetermined: string[];
|
65 | }
|
66 |
|
67 | /**
|
68 | * @public
|
69 | */
|
70 | export declare interface Extractors {
|
71 | extensions: string[];
|
72 | extractor: ExtractorFunction;
|
73 | }
|
74 |
|
75 | /**
|
76 | * PostCSS Plugin for PurgeCSS
|
77 | *
|
78 | * @param opts - PurgeCSS Options
|
79 | * @returns the postCSS plugin
|
80 | *
|
81 | * @public
|
82 | */
|
83 | declare const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions>;
|
84 | export default purgeCSSPlugin;
|
85 |
|
86 | /**
|
87 | * Options used by PurgeCSS to remove unused CSS
|
88 | *
|
89 | * @public
|
90 | */
|
91 | export declare interface PurgeCSSUserDefinedOptions {
|
92 | /** {@inheritDoc purgecss#Options.content} */
|
93 | content: Array<string | RawContent>;
|
94 | /** {@inheritDoc purgecss#Options.css} */
|
95 | css: Array<string | RawCSS>;
|
96 | /** {@inheritDoc purgecss#Options.defaultExtractor} */
|
97 | defaultExtractor?: ExtractorFunction;
|
98 | /** {@inheritDoc purgecss#Options.extractors} */
|
99 | extractors?: Array<Extractors>;
|
100 | /** {@inheritDoc purgecss#Options.fontFace} */
|
101 | fontFace?: boolean;
|
102 | /** {@inheritDoc purgecss#Options.keyframes} */
|
103 | keyframes?: boolean;
|
104 | /** {@inheritDoc purgecss#Options.output} */
|
105 | output?: string;
|
106 | /** {@inheritDoc purgecss#Options.rejected} */
|
107 | rejected?: boolean;
|
108 | /** {@inheritDoc purgecss#Options.rejectedCss} */
|
109 | rejectedCss?: boolean;
|
110 | /** {@inheritDoc purgecss#Options.sourceMap } */
|
111 | sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
|
112 | /** {@inheritDoc purgecss#Options.stdin} */
|
113 | stdin?: boolean;
|
114 | /** {@inheritDoc purgecss#Options.stdout} */
|
115 | stdout?: boolean;
|
116 | /** {@inheritDoc purgecss#Options.variables} */
|
117 | variables?: boolean;
|
118 | /** {@inheritDoc purgecss#Options.safelist} */
|
119 | safelist?: UserDefinedSafelist;
|
120 | /** {@inheritDoc purgecss#Options.blocklist} */
|
121 | blocklist?: StringRegExpArray;
|
122 | /** {@inheritDoc purgecss#Options.skippedContentGlobs} */
|
123 | skippedContentGlobs?: Array<string>;
|
124 | /** {@inheritDoc purgecss#Options.dynamicAttributes} */
|
125 | dynamicAttributes?: string[];
|
126 | }
|
127 |
|
128 | /**
|
129 | * @public
|
130 | */
|
131 | export declare interface RawContent<T = string> {
|
132 | extension: string;
|
133 | raw: T;
|
134 | }
|
135 |
|
136 | /**
|
137 | * @public
|
138 | */
|
139 | export declare interface RawCSS {
|
140 | raw: string;
|
141 | name?: string;
|
142 | }
|
143 |
|
144 | /**
|
145 | * @public
|
146 | */
|
147 | export declare type StringRegExpArray = Array<RegExp | string>;
|
148 |
|
149 | /**
|
150 | * {@inheritDoc purgecss#UserDefinedOptions}
|
151 | *
|
152 | * @public
|
153 | */
|
154 | export declare interface UserDefinedOptions extends Omit<PurgeCSSUserDefinedOptions, "content" | "css"> {
|
155 | content?: PurgeCSSUserDefinedOptions["content"];
|
156 | contentFunction?: (sourceFile: string) => Array<string | RawContent>;
|
157 | }
|
158 |
|
159 | /**
|
160 | * @public
|
161 | */
|
162 | export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
163 |
|
164 | export { }
|