保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Type definitions for webpack-dev-middleware 4.1
// Project: https://github.com/webpack/webpack-dev-middleware
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
//                 reduckted <https://github.com/reduckted>
//                 Chris Abrams <https://github.com/chrisabrams>
//                 Piotr Błażejewicz <https://github.com/peterblazejewicz>
//                 Ma Tianqi <https://github.com/tqma113>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.7
 
import * as webpack from 'webpack';
import { NextHandleFunction } from 'connect';
 
export = WebpackDevMiddleware;
 
declare function WebpackDevMiddleware(
    compiler: webpack.Compiler | webpack.MultiCompiler,
    options?: WebpackDevMiddleware.Options,
): WebpackDevMiddleware.WebpackDevMiddleware & NextHandleFunction;
 
declare namespace WebpackDevMiddleware {
    interface Options {
        /**
         * This property allows a user to register custom mime types or extension mappings
         */
        mimeTypes?: MimeTypeMap;
        /**
         * If true, the option will instruct the module to write files to the configured location on disk as specified in your webpack config file
         * This option also accepts a Function value, which can be used to filter which files are written to disk
         */
        writeToDisk?: boolean | ((filename: string) => boolean);
        /**
         * This property allows a user to pass the list of HTTP request methods accepted by the server.
         * @default [ 'GET', 'HEAD' ]
         */
        methods?: string[];
        /** This property allows a user to pass custom HTTP headers on each request. eg. { "X-Custom-Header": "yes" } */
        headers?: {
            [name: string]: string;
        };
        /** The public path that the middleware is bound to */
        publicPath?: string;
        /** Instructs the module to enable or disable the server-side rendering mode */
        serverSideRender?: boolean;
        /** Stats options object or preset name. */
        stats?: webpack.Stats.ToJsonOptions;
        /**
         * Set the default file system which will be used by webpack as primary destination of generated files
         */
        outputFileSystem?: webpack.Compiler['outputFileSystem'];
        /**
         * The index path for web server, defaults to "index.html".
         * If falsy (but not undefined), the server will not respond to requests to the root URL.
         */
        index?: string | boolean;
    }
 
    interface MimeTypeMap {
        [type: string]: string;
    }
 
    type Callback = (stats?: webpack.Stats) => void;
 
    interface Context {
        state: boolean;
        stats: webpack.Stats | null;
        callbacks: Callback[];
        options: Options;
        compiler: webpack.Compiler;
        watching: webpack.Watching | null;
    }
 
    interface WebpackDevMiddleware {
        /** Executes a callback function when the compiler bundle is valid, typically after compilation */
        waitUntilValid(callback?: Callback): void;
        /** Instructs a webpack-dev-middleware instance to recompile the bundle. e.g. after a change to the configuration. */
        invalidate(callback?: Callback): void;
        /** A function executed once the middleware has stopped watching. */
        close(callback?: () => void): void;
        context: Context;
    }
}