UNPKG

3.1 kBTypeScriptView Raw
1// Type definitions for webpack-dev-server 2.9
2// Project: https://github.com/webpack/webpack-dev-server
3// Definitions by: maestroh <https://github.com/maestroh>
4// Dave Parslow <https://github.com/daveparslow>
5// Zheyang Song <https://github.com/ZheyangSong>
6// Alan Agius <https://github.com/alan-agius4>
7// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
8// TypeScript Version: 2.3
9
10import * as webpack from 'webpack';
11import * as core from 'express-serve-static-core';
12import * as serveStatic from 'serve-static';
13import * as http from 'http';
14import * as spdy from 'spdy';
15import * as httpProxyMiddleware from 'http-proxy-middleware';
16
17declare namespace WebpackDevServer {
18 interface ListeningApp {
19 address(): { port?: number };
20 }
21
22 interface proxyConfigMap {
23 [url: string]: string | httpProxyMiddleware.Config;
24 }
25
26 type proxyConfigArrayItem = {
27 path?: string | string[];
28 context?: string | string[]
29 } & httpProxyMiddleware.Config;
30
31 type proxyConfigArray = proxyConfigArrayItem[];
32
33 type expressAppHook = (app: core.Express) => void;
34
35 interface Configuration {
36 after?: expressAppHook;
37 allowedHosts?: string[];
38 before?: expressAppHook;
39 bonjour?: boolean;
40 clientLogLevel?: string;
41 compress?: boolean;
42 contentBase?: string;
43 disableHostCheck?: boolean;
44 filename?: string;
45 headers?: {};
46 historyApiFallback?: boolean | {};
47 host?: string;
48 hot?: boolean;
49 hotOnly?: boolean;
50 https?: boolean | spdy.ServerOptions;
51 inline?: boolean;
52 lazy?: boolean;
53 noInfo?: boolean;
54 open?: boolean;
55 openPage?: string;
56 overlay?: boolean | {
57 warnings: boolean;
58 errors: boolean;
59 };
60 pfx?: string;
61 pfxPassphrase?: string;
62 port?: number;
63 proxy?: proxyConfigMap | proxyConfigArray;
64 public?: string;
65 publicPath?: string;
66 quiet?: boolean;
67 setup?: expressAppHook; // will be depreacted in v3.0.0 and replaced by before
68 socket?: string;
69 staticOptions?: serveStatic.ServeStaticOptions;
70 stats?: webpack.compiler.StatsOptions | webpack.compiler.StatsToStringOptions;
71 useLocalIp?: boolean;
72 watchContentBase?: boolean;
73 watchOptions?: webpack.WatchOptions;
74 }
75}
76
77declare class WebpackDevServer {
78 constructor(
79 webpack: webpack.Compiler | webpack.MultiCompiler,
80 config: WebpackDevServer.Configuration
81 );
82
83 static addDevServerEntrypoints(
84 webpackOptions: webpack.Configuration | webpack.Configuration[],
85 config: WebpackDevServer.Configuration,
86 listeningApp?: WebpackDevServer.ListeningApp
87 ): void;
88
89 listen(port: number, hostname: string, callback?: (error?: Error) => void): http.Server;
90
91 listen(port: number, callback?: (error?: Error) => void): http.Server;
92
93 close(callback?: () => void): void;
94}
95
96export = WebpackDevServer;