1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import * as webpack from "webpack";
|
12 | import { IncomingMessage, NextHandleFunction } from "connect";
|
13 | import { ServerResponse } from "http";
|
14 |
|
15 | export = WebpackDevMiddleware;
|
16 |
|
17 | declare function WebpackDevMiddleware(
|
18 | compiler: webpack.Compiler | webpack.MultiCompiler,
|
19 | options?: WebpackDevMiddleware.Options,
|
20 | ): WebpackDevMiddleware.WebpackDevMiddleware & NextHandleFunction;
|
21 |
|
22 | declare namespace WebpackDevMiddleware {
|
23 | interface Options {
|
24 | |
25 |
|
26 |
|
27 | mimeTypes?: MimeTypeMap;
|
28 | |
29 |
|
30 |
|
31 |
|
32 | writeToDisk?: boolean | ((filename: string) => boolean);
|
33 | /**
|
34 | * This property allows a user to pass the list of HTTP request methods accepted by the server.
|
35 | * @default [ 'GET', 'HEAD' ]
|
36 | */
|
37 | methods?: string[];
|
38 | /** This property allows a user to pass custom HTTP headers on each request. eg. { "X-Custom-Header": "yes" } */
|
39 | headers?: Record<string, string> | HeadersHandle;
|
40 | /** The public path that the middleware is bound to */
|
41 | publicPath?: string;
|
42 | /** Instructs the module to enable or disable the server-side rendering mode */
|
43 | serverSideRender?: boolean;
|
44 | /** Stats options object or preset name. */
|
45 | stats?: webpack.Configuration['stats'];
|
46 | /**
|
47 | * Set the default file system which will be used by webpack as primary destination of generated files
|
48 | */
|
49 | outputFileSystem?: webpack.Compiler['outputFileSystem'];
|
50 | /**
|
51 | * The index path for web server, defaults to "index.html".
|
52 | * If falsy (but not undefined), the server will not respond to requests to the root URL.
|
53 | */
|
54 | index?: string | boolean;
|
55 | }
|
56 |
|
57 | interface MimeTypeMap {
|
58 | [type: string]: string;
|
59 | }
|
60 |
|
61 | type Callback = (stats?: webpack.Stats) => void;
|
62 |
|
63 | interface Context {
|
64 | state: boolean;
|
65 | stats: webpack.Stats | null;
|
66 | callbacks: Callback[];
|
67 | options: Options;
|
68 | compiler: webpack.Compiler;
|
69 | watching: webpack.Watching | null;
|
70 | }
|
71 |
|
72 | interface WebpackDevMiddleware {
|
73 |
|
74 | waitUntilValid(callback?: Callback): void;
|
75 |
|
76 | invalidate(callback?: Callback): void;
|
77 |
|
78 | close(callback?: () => void): void;
|
79 | |
80 |
|
81 |
|
82 |
|
83 | getFilenameFromUrl(url: string): string | undefined;
|
84 | context: Context;
|
85 | }
|
86 |
|
87 | interface HeadersHandle {
|
88 | (req: IncomingMessage, res: ServerResponse, context: Context): Record<string, string> | void;
|
89 | }
|
90 | }
|