UNPKG

8.17 kBTypeScriptView Raw
1export = MiniCssExtractPlugin;
2declare class MiniCssExtractPlugin {
3 /**
4 * @param {Compiler["webpack"]} webpack
5 * @returns {CssModuleConstructor}
6 */
7 static getCssModule(webpack: Compiler["webpack"]): CssModuleConstructor;
8 /**
9 * @param {Compiler["webpack"]} webpack
10 * @returns {CssDependencyConstructor}
11 */
12 static getCssDependency(
13 webpack: Compiler["webpack"]
14 ): CssDependencyConstructor;
15 /**
16 * Returns all hooks for the given compilation
17 * @param {Compilation} compilation
18 */
19 static getCompilationHooks(
20 compilation: Compilation
21 ): MiniCssExtractPluginCompilationHooks;
22 /**
23 * @param {PluginOptions} [options]
24 */
25 constructor(options?: PluginOptions | undefined);
26 /**
27 * @private
28 * @type {WeakMap<Chunk, Set<CssModule>>}
29 * @private
30 */
31 private _sortedModulesCache;
32 /**
33 * @private
34 * @type {NormalizedPluginOptions}
35 */
36 private options;
37 /**
38 * @private
39 * @type {RuntimeOptions}
40 */
41 private runtimeOptions;
42 /**
43 * @param {Compiler} compiler
44 */
45 apply(compiler: Compiler): void;
46 /**
47 * @private
48 * @param {Chunk} chunk
49 * @param {ChunkGraph} chunkGraph
50 * @returns {Iterable<Module>}
51 */
52 private getChunkModules;
53 /**
54 * @private
55 * @param {Compilation} compilation
56 * @param {Chunk} chunk
57 * @param {CssModule[]} modules
58 * @param {Compilation["requestShortener"]} requestShortener
59 * @returns {Set<CssModule>}
60 */
61 private sortModules;
62 /**
63 * @private
64 * @param {Compiler} compiler
65 * @param {Compilation} compilation
66 * @param {Chunk} chunk
67 * @param {CssModule[]} modules
68 * @param {Compiler["requestShortener"]} requestShortener
69 * @param {string} filenameTemplate
70 * @param {Parameters<Exclude<Required<Configuration>['output']['filename'], string | undefined>>[0]} pathData
71 * @returns {Source}
72 */
73 private renderContentAsset;
74}
75declare namespace MiniCssExtractPlugin {
76 export {
77 pluginName,
78 pluginSymbol,
79 loader,
80 Schema,
81 Compiler,
82 Compilation,
83 ChunkGraph,
84 Chunk,
85 ChunkGroup,
86 Module,
87 Dependency,
88 Source,
89 Configuration,
90 WebpackError,
91 AssetInfo,
92 LoaderDependency,
93 LoaderOptions,
94 PluginOptions,
95 NormalizedPluginOptions,
96 RuntimeOptions,
97 TODO,
98 CssModule,
99 CssModuleDependency,
100 CssModuleConstructor,
101 CssDependency,
102 CssDependencyOptions,
103 CssDependencyConstructor,
104 VarNames,
105 MiniCssExtractPluginCompilationHooks,
106 };
107}
108type Compiler = import("webpack").Compiler;
109type CssModuleConstructor = new (dependency: CssModuleDependency) => CssModule;
110type CssDependencyConstructor = new (
111 loaderDependency: CssDependencyOptions,
112 context: string | null,
113 identifierIndex: number
114) => CssDependency;
115type Compilation = import("webpack").Compilation;
116type MiniCssExtractPluginCompilationHooks = {
117 beforeTagInsert: import("tapable").SyncWaterfallHook<
118 [string, VarNames],
119 string
120 >;
121};
122type PluginOptions = {
123 filename?: Required<Configuration>["output"]["filename"];
124 chunkFilename?: Required<Configuration>["output"]["chunkFilename"];
125 ignoreOrder?: boolean | undefined;
126 insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
127 attributes?: Record<string, string> | undefined;
128 linkType?: string | false | undefined;
129 runtime?: boolean | undefined;
130 experimentalUseImportModule?: boolean | undefined;
131};
132/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
133/** @typedef {import("webpack").Compiler} Compiler */
134/** @typedef {import("webpack").Compilation} Compilation */
135/** @typedef {import("webpack").ChunkGraph} ChunkGraph */
136/** @typedef {import("webpack").Chunk} Chunk */
137/** @typedef {Parameters<import("webpack").Chunk["isInGroup"]>[0]} ChunkGroup */
138/** @typedef {import("webpack").Module} Module */
139/** @typedef {import("webpack").Dependency} Dependency */
140/** @typedef {import("webpack").sources.Source} Source */
141/** @typedef {import("webpack").Configuration} Configuration */
142/** @typedef {import("webpack").WebpackError} WebpackError */
143/** @typedef {import("webpack").AssetInfo} AssetInfo */
144/** @typedef {import("./loader.js").Dependency} LoaderDependency */
145/**
146 * @typedef {Object} LoaderOptions
147 * @property {string | ((resourcePath: string, rootContext: string) => string)} [publicPath]
148 * @property {boolean} [emit]
149 * @property {boolean} [esModule]
150 * @property {string} [layer]
151 */
152/**
153 * @typedef {Object} PluginOptions
154 * @property {Required<Configuration>['output']['filename']} [filename]
155 * @property {Required<Configuration>['output']['chunkFilename']} [chunkFilename]
156 * @property {boolean} [ignoreOrder]
157 * @property {string | ((linkTag: HTMLLinkElement) => void)} [insert]
158 * @property {Record<string, string>} [attributes]
159 * @property {string | false | 'text/css'} [linkType]
160 * @property {boolean} [runtime]
161 * @property {boolean} [experimentalUseImportModule]
162 */
163/**
164 * @typedef {Object} NormalizedPluginOptions
165 * @property {Required<Configuration>['output']['filename']} filename
166 * @property {Required<Configuration>['output']['chunkFilename']} [chunkFilename]
167 * @property {boolean} ignoreOrder
168 * @property {string | ((linkTag: HTMLLinkElement) => void)} [insert]
169 * @property {Record<string, string>} [attributes]
170 * @property {string | false | 'text/css'} [linkType]
171 * @property {boolean} runtime
172 * @property {boolean} [experimentalUseImportModule]
173 */
174/**
175 * @typedef {Object} RuntimeOptions
176 * @property {string | ((linkTag: HTMLLinkElement) => void) | undefined} insert
177 * @property {string | false | 'text/css'} linkType
178 * @property {Record<string, string> | undefined} attributes
179 */
180/** @typedef {any} TODO */
181declare const pluginName: "mini-css-extract-plugin";
182declare const pluginSymbol: unique symbol;
183declare var loader: string;
184type Schema = import("schema-utils/declarations/validate").Schema;
185type ChunkGraph = import("webpack").ChunkGraph;
186type Chunk = import("webpack").Chunk;
187type ChunkGroup = Parameters<import("webpack").Chunk["isInGroup"]>[0];
188type Module = import("webpack").Module;
189type Dependency = import("webpack").Dependency;
190type Source = import("webpack").sources.Source;
191type Configuration = import("webpack").Configuration;
192type WebpackError = import("webpack").WebpackError;
193type AssetInfo = import("webpack").AssetInfo;
194type LoaderDependency = import("./loader.js").Dependency;
195type LoaderOptions = {
196 publicPath?:
197 | string
198 | ((resourcePath: string, rootContext: string) => string)
199 | undefined;
200 emit?: boolean | undefined;
201 esModule?: boolean | undefined;
202 layer?: string | undefined;
203};
204type NormalizedPluginOptions = {
205 filename: Required<Configuration>["output"]["filename"];
206 chunkFilename?: Required<Configuration>["output"]["chunkFilename"];
207 ignoreOrder: boolean;
208 insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
209 attributes?: Record<string, string> | undefined;
210 linkType?: string | false | undefined;
211 runtime: boolean;
212 experimentalUseImportModule?: boolean | undefined;
213};
214type RuntimeOptions = {
215 insert: string | ((linkTag: HTMLLinkElement) => void) | undefined;
216 linkType: string | false | "text/css";
217 attributes: Record<string, string> | undefined;
218};
219type TODO = any;
220type CssModule = import("webpack").Module & {
221 content: Buffer;
222 media?: string | undefined;
223 sourceMap?: Buffer | undefined;
224 supports?: string | undefined;
225 layer?: string | undefined;
226 assets?:
227 | {
228 [key: string]: any;
229 }
230 | undefined;
231 assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
232};
233type CssModuleDependency = {
234 context: string | null;
235 identifier: string;
236 identifierIndex: number;
237 content: Buffer;
238 sourceMap?: Buffer | undefined;
239 media?: string | undefined;
240 supports?: string | undefined;
241 layer?: TODO;
242 assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
243 assets?:
244 | {
245 [key: string]: any;
246 }
247 | undefined;
248};
249type CssDependency = Dependency & CssModuleDependency;
250type CssDependencyOptions = Omit<LoaderDependency, "context">;
251type VarNames = {
252 tag: string;
253 chunkId: string;
254 href: string;
255 resolve: string;
256 reject: string;
257};
258
\No newline at end of file