UNPKG

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