UNPKG

2.26 kBTypeScriptView Raw
1import { Loader, Plugin } from "webpack";
2
3export = ExtractTextPlugin;
4
5/**
6 * Use an `ExtractTextPlugin` instance and a loader returned by `extract` in concert to write files to disk instead of loading them into others.
7 * Usage example at https://github.com/webpack/extract-text-webpack-plugin#usage-example-with-css
8 */
9declare class ExtractTextPlugin extends Plugin {
10 /** Create a plugin instance defining the extraction target file(s) for the files loaded by `extract` */
11 constructor(options: string | ExtractTextPlugin.PluginOptions);
12 /**
13 * Creates an extracting loader from an existing loader (static).
14 * Use the resulting loader in `module.rules`/`module.loaders`.
15 * @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#extract}
16 */
17 static extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
18 /**
19 * Creates an extracting loader from an existing loader (instance).
20 * Use the resulting loader in `module.rules`/`module.loaders`.
21 * @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#multiple-instances}
22 */
23 extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
24}
25
26declare namespace ExtractTextPlugin {
27 interface PluginOptions {
28 /** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
29 filename: string;
30 /** extract from all additional chunks too (by default it extracts only from the initial chunk(s)) */
31 allChunks?: boolean | undefined;
32 /** disables the plugin */
33 disable?: boolean | undefined;
34 /** Unique ident for this plugin instance. (For advanced usage only, by default automatically generated) */
35 id?: string | undefined;
36 }
37 interface LoaderOptions {
38 /** the loader(s) that should be used for converting the resource to a css exporting module */
39 use: Loader | Loader[];
40 /** the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when `allChunks: false`) */
41 fallback?: Loader | Loader[] | undefined;
42 /** override the `publicPath` setting for this loader */
43 publicPath?: string | undefined;
44 }
45}