UNPKG

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