1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | import * as webpack from 'webpack';
|
15 | import * as httpProxyMiddleware from 'http-proxy-middleware';
|
16 | import * as express from 'express';
|
17 | import * as serveStatic from 'serve-static';
|
18 | import * as https from 'https';
|
19 | import * as http from 'http';
|
20 | import * as connectHistoryApiFallback from 'connect-history-api-fallback';
|
21 |
|
22 | declare namespace WebpackDevServer {
|
23 | interface ListeningApp {
|
24 | address(): { port?: number };
|
25 | }
|
26 |
|
27 | interface ProxyConfigMap {
|
28 | [url: string]: string | httpProxyMiddleware.Config;
|
29 | }
|
30 |
|
31 | type ProxyConfigArrayItem = {
|
32 | path?: string | string[];
|
33 | context?: string | string[] | httpProxyMiddleware.Filter;
|
34 | } & httpProxyMiddleware.Config;
|
35 |
|
36 | type ProxyConfigArray = ProxyConfigArrayItem[];
|
37 |
|
38 | interface Configuration {
|
39 |
|
40 | after?: (app: express.Application, server: WebpackDevServer, compiler: webpack.Compiler) => void;
|
41 |
|
42 | allowedHosts?: string[];
|
43 |
|
44 | before?: (app: express.Application, server: WebpackDevServer, compiler: webpack.Compiler) => void;
|
45 |
|
46 | bonjour?: boolean;
|
47 | |
48 |
|
49 |
|
50 |
|
51 | clientLogLevel?: 'none' | 'error' | 'warning' | 'info';
|
52 |
|
53 | compress?: boolean;
|
54 | |
55 |
|
56 |
|
57 |
|
58 | contentBase?: boolean | string | string[];
|
59 | |
60 |
|
61 |
|
62 |
|
63 | disableHostCheck?: boolean;
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 | filename?: string;
|
70 |
|
71 | headers?: {
|
72 | [key: string]: string;
|
73 | };
|
74 |
|
75 | historyApiFallback?: boolean | connectHistoryApiFallback.Options;
|
76 |
|
77 | host?: string;
|
78 |
|
79 | hot?: boolean;
|
80 |
|
81 | hotOnly?: boolean;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | http2?: boolean;
|
88 |
|
89 | https?: boolean | https.ServerOptions;
|
90 |
|
91 | index?: string;
|
92 | |
93 |
|
94 |
|
95 |
|
96 | injectClient?: boolean | ((compilerConfig: webpack.Compiler) => boolean);
|
97 | /**
|
98 | * Tells devServer to inject a Hot Module Replacement. Setting devServer.injectHot
|
99 | * to true will result in always injecting. It is possible to provide a function to
|
100 | * inject conditionally
|
101 | */
|
102 | injectHot?: boolean | ((compilerConfig: webpack.Compiler) => boolean);
|
103 | /**
|
104 | * Toggle between the dev-server's two different modes.
|
105 | * By default the application will be served with inline mode enabled.
|
106 | * This means that a script will be inserted in your bundle to take care of live reloading,
|
107 | * and build messages will appear in the browser console.
|
108 | */
|
109 | inline?: boolean;
|
110 | /**
|
111 | * When lazy is enabled, the dev-server will only compile the bundle when it gets requested.
|
112 | * This means that webpack will not watch any file changes.
|
113 | */
|
114 | lazy?: boolean;
|
115 | /**
|
116 | * By default, the dev-server will reload/refresh the page when file changes are detected.
|
117 | */
|
118 | liveReload?: boolean;
|
119 | /**
|
120 | * Allows dev-server to register custom mime types.
|
121 | */
|
122 | mimeTypes?:
|
123 | | {
|
124 | [key: string]: string[];
|
125 | }
|
126 | | {
|
127 | typeMap?: {
|
128 | [key: string]: string[];
|
129 | } & {
|
130 | force: boolean;
|
131 | };
|
132 | };
|
133 | /**
|
134 | * With noInfo enabled, messages like the webpack bundle information that is shown
|
135 | * when starting up and after each save,will be hidden.
|
136 | * Errors and warnings will still be shown.
|
137 | */
|
138 | noInfo?: boolean;
|
139 | /** When open is enabled, the dev server will open the browser. */
|
140 | open?: boolean;
|
141 | /** Specify a page to navigate to when opening the browser. */
|
142 | openPage?: string;
|
143 | /** Shows a full-screen overlay in the browser when there are compiler errors or warnings. Disabled by default. */
|
144 | overlay?:
|
145 | | boolean
|
146 | | {
|
147 | warnings?: boolean;
|
148 | errors?: boolean;
|
149 | };
|
150 | /** When used via the CLI, a path to an SSL .pfx file. If used in options, it should be the bytestream of the .pfx file. */
|
151 | pfx?: string;
|
152 | /** The passphrase to a SSL PFX file. */
|
153 | pfxPassphrase?: string;
|
154 | /** Specify a port number to listen for requests on. */
|
155 | port?: number;
|
156 | /**
|
157 | * Proxying some URLs can be useful when you have a separate API backend development server
|
158 | * and you want to send API requests on the same domain.
|
159 | */
|
160 | proxy?: ProxyConfigMap | ProxyConfigArray;
|
161 | /**
|
162 | * When using inline mode and you're proxying dev-server,
|
163 | * the inline client script does not always know where to connect to.
|
164 | * It will try to guess the URL of the server based on window.location, but if that fails you'll need to use this.
|
165 | */
|
166 | public?: string;
|
167 | /** The bundled files will be available in the browser under this path. */
|
168 | publicPath?: string;
|
169 | /**
|
170 | * With quiet enabled, nothing except the initial startup information will be written to the console.
|
171 | * This also means that errors or warnings from webpack are not visible.
|
172 | */
|
173 | quiet?: boolean;
|
174 | /**
|
175 | * Tells dev-server to use serveIndex middleware when enabled.
|
176 | */
|
177 | serveIndex?: boolean;
|
178 | /** @deprecated Here you can access the Express app object and add your own custom middleware to it. */
|
179 | setup?: (app: express.Application, server: WebpackDevServer) => void;
|
180 |
|
181 | socket?: string;
|
182 | |
183 |
|
184 |
|
185 | sockHost?: string;
|
186 |
|
187 | sockPath?: string;
|
188 |
|
189 | staticOptions?: serveStatic.ServeStaticOptions;
|
190 | |
191 |
|
192 |
|
193 |
|
194 | stats?: webpack.Options.Stats;
|
195 |
|
196 | useLocalIp?: boolean;
|
197 |
|
198 | watchContentBase?: boolean;
|
199 |
|
200 | watchOptions?: webpack.WatchOptions;
|
201 |
|
202 | writeToDisk?: boolean | ((filePath: string) => boolean);
|
203 | }
|
204 | }
|
205 |
|
206 | declare module 'webpack' {
|
207 | interface Configuration {
|
208 | /** Can be used to configure the behaviour of webpack-dev-server when the webpack config is passed to webpack-dev-server CLI. */
|
209 | devServer?: WebpackDevServer.Configuration;
|
210 | }
|
211 | }
|
212 |
|
213 | declare class WebpackDevServer {
|
214 | constructor(webpack: webpack.Compiler | webpack.MultiCompiler, config?: WebpackDevServer.Configuration);
|
215 |
|
216 | static addDevServerEntrypoints(
|
217 | webpackOptions: webpack.Configuration | webpack.Configuration[],
|
218 | config: WebpackDevServer.Configuration,
|
219 | listeningApp?: WebpackDevServer.ListeningApp,
|
220 | ): void;
|
221 |
|
222 | listen(port: number, hostname: string, callback?: (error?: Error) => void): http.Server;
|
223 |
|
224 | listen(port: number, callback?: (error?: Error) => void): http.Server;
|
225 |
|
226 | close(callback?: () => void): void;
|
227 | }
|
228 |
|
229 | export = WebpackDevServer;
|
230 |
|
\ | No newline at end of file |