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 | export { purgeCSSPlugin }
|
86 |
|
87 | /**
|
88 | * Options used by PurgeCSS to remove unused CSS
|
89 | *
|
90 | * @public
|
91 | */
|
92 | export declare interface PurgeCSSUserDefinedOptions {
|
93 | /** {@inheritDoc purgecss#Options.content} */
|
94 | content: Array<string | RawContent>;
|
95 | /** {@inheritDoc purgecss#Options.css} */
|
96 | css: Array<string | RawCSS>;
|
97 | /** {@inheritDoc purgecss#Options.defaultExtractor} */
|
98 | defaultExtractor?: ExtractorFunction;
|
99 | /** {@inheritDoc purgecss#Options.extractors} */
|
100 | extractors?: Array<Extractors>;
|
101 | /** {@inheritDoc purgecss#Options.fontFace} */
|
102 | fontFace?: boolean;
|
103 | /** {@inheritDoc purgecss#Options.keyframes} */
|
104 | keyframes?: boolean;
|
105 | /** {@inheritDoc purgecss#Options.output} */
|
106 | output?: string;
|
107 | /** {@inheritDoc purgecss#Options.rejected} */
|
108 | rejected?: boolean;
|
109 | /** {@inheritDoc purgecss#Options.rejectedCss} */
|
110 | rejectedCss?: boolean;
|
111 | /** {@inheritDoc purgecss#Options.sourceMap } */
|
112 | sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
|
113 | /** {@inheritDoc purgecss#Options.stdin} */
|
114 | stdin?: boolean;
|
115 | /** {@inheritDoc purgecss#Options.stdout} */
|
116 | stdout?: boolean;
|
117 | /** {@inheritDoc purgecss#Options.variables} */
|
118 | variables?: boolean;
|
119 | /** {@inheritDoc purgecss#Options.safelist} */
|
120 | safelist?: UserDefinedSafelist;
|
121 | /** {@inheritDoc purgecss#Options.blocklist} */
|
122 | blocklist?: StringRegExpArray;
|
123 | /** {@inheritDoc purgecss#Options.skippedContentGlobs} */
|
124 | skippedContentGlobs?: Array<string>;
|
125 | /** {@inheritDoc purgecss#Options.dynamicAttributes} */
|
126 | dynamicAttributes?: string[];
|
127 | }
|
128 |
|
129 | /**
|
130 | * @public
|
131 | */
|
132 | export declare interface RawContent<T = string> {
|
133 | extension: string;
|
134 | raw: T;
|
135 | }
|
136 |
|
137 | /**
|
138 | * @public
|
139 | */
|
140 | export declare interface RawCSS {
|
141 | raw: string;
|
142 | name?: string;
|
143 | }
|
144 |
|
145 | /**
|
146 | * @public
|
147 | */
|
148 | export declare type StringRegExpArray = Array<RegExp | string>;
|
149 |
|
150 | /**
|
151 | * {@inheritDoc purgecss#UserDefinedOptions}
|
152 | *
|
153 | * @public
|
154 | */
|
155 | export declare interface UserDefinedOptions extends Omit<PurgeCSSUserDefinedOptions, "content" | "css"> {
|
156 | content?: PurgeCSSUserDefinedOptions["content"];
|
157 | contentFunction?: (sourceFile: string) => Array<string | RawContent>;
|
158 | }
|
159 |
|
160 | /**
|
161 | * @public
|
162 | */
|
163 | export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
164 |
|
165 | export { }
|