1 | export = CssMinimizerPlugin;
|
2 |
|
3 |
|
4 |
|
5 | declare class CssMinimizerPlugin<T = CssNanoOptionsExtended> {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 | private static isSourceMap;
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | private static buildWarning;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | private static buildError;
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 | private static getAvailableNumberOfCores;
|
37 | |
38 |
|
39 |
|
40 | constructor(
|
41 | options?:
|
42 | | (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>)
|
43 | | undefined
|
44 | );
|
45 | /**
|
46 | * @private
|
47 | * @type {InternalPluginOptions<T>}
|
48 | */
|
49 | private options;
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | private optimize;
|
59 | |
60 |
|
61 |
|
62 |
|
63 | apply(compiler: Compiler): void;
|
64 | }
|
65 | declare namespace CssMinimizerPlugin {
|
66 | export {
|
67 | cssnanoMinify,
|
68 | cssoMinify,
|
69 | cleanCssMinify,
|
70 | esbuildMinify,
|
71 | parcelCssMinify,
|
72 | Schema,
|
73 | Compiler,
|
74 | Compilation,
|
75 | WebpackError,
|
76 | JestWorker,
|
77 | RawSourceMap,
|
78 | Asset,
|
79 | ProcessOptions,
|
80 | Syntax,
|
81 | Parser,
|
82 | Stringifier,
|
83 | CssNanoOptions,
|
84 | Warning,
|
85 | WarningObject,
|
86 | ErrorObject,
|
87 | MinimizedResult,
|
88 | Input,
|
89 | CustomOptions,
|
90 | InferDefaultType,
|
91 | BasicMinimizerImplementation,
|
92 | MinimizerImplementation,
|
93 | MinimizerOptions,
|
94 | InternalOptions,
|
95 | InternalResult,
|
96 | Parallel,
|
97 | Rule,
|
98 | Rules,
|
99 | WarningsFilter,
|
100 | BasePluginOptions,
|
101 | MinimizerWorker,
|
102 | ProcessOptionsExtender,
|
103 | CssNanoOptionsExtended,
|
104 | DefinedDefaultMinimizerAndOptions,
|
105 | InternalPluginOptions,
|
106 | };
|
107 | }
|
108 | type CssNanoOptionsExtended = CssNanoOptions & {
|
109 | processorOptions?: ProcessOptionsExtender;
|
110 | };
|
111 | type Compiler = import("webpack").Compiler;
|
112 | type BasePluginOptions = {
|
113 | test?: Rules | undefined;
|
114 | include?: Rules | undefined;
|
115 | exclude?: Rules | undefined;
|
116 | warningsFilter?: WarningsFilter | undefined;
|
117 | parallel?: Parallel;
|
118 | };
|
119 | type DefinedDefaultMinimizerAndOptions<T> = T extends CssNanoOptionsExtended
|
120 | ? {
|
121 | minify?: MinimizerImplementation<T> | undefined;
|
122 | minimizerOptions?: MinimizerOptions<T> | undefined;
|
123 | }
|
124 | : {
|
125 | minify: MinimizerImplementation<T>;
|
126 | minimizerOptions?: MinimizerOptions<T> | undefined;
|
127 | };
|
128 | import { cssnanoMinify } from "./utils";
|
129 | import { cssoMinify } from "./utils";
|
130 | import { cleanCssMinify } from "./utils";
|
131 | import { esbuildMinify } from "./utils";
|
132 | import { parcelCssMinify } from "./utils";
|
133 | type Schema = import("schema-utils/declarations/validate").Schema;
|
134 | type Compilation = import("webpack").Compilation;
|
135 | type WebpackError = import("webpack").WebpackError;
|
136 | type JestWorker = import("jest-worker").Worker;
|
137 | type RawSourceMap = import("source-map").RawSourceMap;
|
138 | type Asset = import("webpack").Asset;
|
139 | type ProcessOptions = import("postcss").ProcessOptions;
|
140 | type Syntax = import("postcss").Syntax;
|
141 | type Parser = import("postcss").Parser;
|
142 | type Stringifier = import("postcss").Stringifier;
|
143 | type CssNanoOptions = {
|
144 | configFile?: string | undefined;
|
145 | preset?: [string, object] | string | undefined;
|
146 | };
|
147 | type Warning =
|
148 | | (Error & {
|
149 | plugin?: string;
|
150 | text?: string;
|
151 | source?: string;
|
152 | })
|
153 | | string;
|
154 | type WarningObject = {
|
155 | message: string;
|
156 | plugin?: string | undefined;
|
157 | text?: string | undefined;
|
158 | line?: number | undefined;
|
159 | column?: number | undefined;
|
160 | };
|
161 | type ErrorObject = {
|
162 | message: string;
|
163 | line?: number | undefined;
|
164 | column?: number | undefined;
|
165 | stack?: string | undefined;
|
166 | };
|
167 | type MinimizedResult = {
|
168 | code: string;
|
169 | map?: import("source-map").RawSourceMap | undefined;
|
170 | errors?: (string | Error | ErrorObject)[] | undefined;
|
171 | warnings?: (Warning | WarningObject)[] | undefined;
|
172 | };
|
173 | type Input = {
|
174 | [file: string]: string;
|
175 | };
|
176 | type CustomOptions = {
|
177 | [key: string]: any;
|
178 | };
|
179 | type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
|
180 | type BasicMinimizerImplementation<T> = (
|
181 | input: Input,
|
182 | sourceMap: RawSourceMap | undefined,
|
183 | minifyOptions: InferDefaultType<T>
|
184 | ) => Promise<MinimizedResult>;
|
185 | type MinimizerImplementation<T> = T extends any[]
|
186 | ? { [P in keyof T]: BasicMinimizerImplementation<T[P]> }
|
187 | : BasicMinimizerImplementation<T>;
|
188 | type MinimizerOptions<T> = T extends any[]
|
189 | ? { [P in keyof T]?: InferDefaultType<T[P]> | undefined }
|
190 | : InferDefaultType<T>;
|
191 | type InternalOptions<T> = {
|
192 | name: string;
|
193 | input: string;
|
194 | inputSourceMap: RawSourceMap | undefined;
|
195 | minimizer: {
|
196 | implementation: MinimizerImplementation<T>;
|
197 | options: MinimizerOptions<T>;
|
198 | };
|
199 | };
|
200 | type InternalResult = {
|
201 | outputs: Array<{
|
202 | code: string;
|
203 | map: RawSourceMap | undefined;
|
204 | }>;
|
205 | warnings: Array<Warning | WarningObject | string>;
|
206 | errors: Array<Error | ErrorObject | string>;
|
207 | };
|
208 | type Parallel = undefined | boolean | number;
|
209 | type Rule = RegExp | string;
|
210 | type Rules = Rule[] | Rule;
|
211 | type WarningsFilter = (
|
212 | warning: Warning | WarningObject | string,
|
213 | file: string,
|
214 | source?: string | undefined
|
215 | ) => boolean;
|
216 | type MinimizerWorker<T> = Worker & {
|
217 | transform: (options: string) => InternalResult;
|
218 | minify: (options: InternalOptions<T>) => InternalResult;
|
219 | };
|
220 | type ProcessOptionsExtender =
|
221 | | ProcessOptions
|
222 | | {
|
223 | from?: string;
|
224 | to?: string;
|
225 | parser?: string | Syntax | Parser;
|
226 | stringifier?: string | Syntax | Stringifier;
|
227 | syntax?: string | Syntax;
|
228 | };
|
229 | type InternalPluginOptions<T> = BasePluginOptions & {
|
230 | minimizer: {
|
231 | implementation: MinimizerImplementation<T>;
|
232 | options: MinimizerOptions<T>;
|
233 | };
|
234 | };
|
235 | import { minify } from "./minify";
|
236 | import { Worker } from "jest-worker";
|