1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import * as webpack from 'webpack';
|
18 | import * as httpProxyMiddleware from 'http-proxy-middleware';
|
19 | import * as express from 'express';
|
20 | import * as serveStatic from 'serve-static';
|
21 | import * as https from 'https';
|
22 | import * as http from 'http';
|
23 | import * as connectHistoryApiFallback from 'connect-history-api-fallback';
|
24 |
|
25 | declare namespace WebpackDevServer {
|
26 | interface ListeningApp {
|
27 | address(): { port?: number | undefined };
|
28 | }
|
29 |
|
30 | interface ProxyConfigMap {
|
31 | [url: string]: string | httpProxyMiddleware.Options;
|
32 | }
|
33 |
|
34 | type ProxyConfigArrayItem = {
|
35 | path?: string | string[] | undefined;
|
36 | context?: string | string[] | httpProxyMiddleware.Filter | undefined;
|
37 | } & httpProxyMiddleware.Options;
|
38 |
|
39 | type ProxyConfigArray = ProxyConfigArrayItem[];
|
40 |
|
41 | interface Configuration {
|
42 | |
43 |
|
44 |
|
45 |
|
46 | after?: ((app: express.Application, server: WebpackDevServer, compiler: webpack.Compiler) => void) | undefined;
|
47 | /**
|
48 | * This option allows you to whitelist services that are allowed to
|
49 | * access the dev server.
|
50 | */
|
51 | allowedHosts?: string[] | undefined;
|
52 | /**
|
53 | * Provides the ability to execute custom middleware prior to all
|
54 | * other middleware internally within the server.
|
55 | */
|
56 | before?: ((app: express.Application, server: WebpackDevServer, compiler: webpack.Compiler) => void) | undefined;
|
57 | /**
|
58 | * This option broadcasts the server via ZeroConf networking on start.
|
59 | */
|
60 | bonjour?: boolean | undefined;
|
61 | /**
|
62 | * When using inline mode, the console in your DevTools will show you
|
63 | * messages e.g. before reloading, before an error or when Hot Module
|
64 | * Replacement is enabled. This may be too verbose.
|
65 | *
|
66 | * 'none' and 'warning' are going to be deprecated at the next major
|
67 | * version.
|
68 | */
|
69 | clientLogLevel?: 'silent' | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'none' | 'warning' | undefined;
|
70 | /**
|
71 | * Enable gzip compression for everything served.
|
72 | */
|
73 | compress?: boolean | undefined;
|
74 | /**
|
75 | * Tell the server where to serve content from. This is only necessary
|
76 | * if you want to serve static files. devServer.publicPath will be used
|
77 | * to determine where the bundles should be served from, and takes
|
78 | * precedence.
|
79 | */
|
80 | contentBase?: boolean | string | string[] | number | undefined;
|
81 | /**
|
82 | * Tell the server at what URL to serve `devServer.contentBase`.
|
83 | * If there was a file `assets/manifest.json`,
|
84 | * it would be served at `/serve-content-base-at-this-url/manifest.json`
|
85 | */
|
86 | contentBasePublicPath?: string | string[] | undefined;
|
87 | /**
|
88 | * When set to true this option bypasses host checking. THIS IS NOT
|
89 | * RECOMMENDED as apps that do not check the host are vulnerable to DNS
|
90 | * rebinding attacks.
|
91 | */
|
92 | disableHostCheck?: boolean | undefined;
|
93 | /**
|
94 | * This option lets you reduce the compilations in lazy mode.
|
95 | * By default in lazy mode, every request results in a new compilation.
|
96 | * With filename, it's possible to only compile when a certain file is requested.
|
97 | */
|
98 | filename?: string | undefined;
|
99 | /** Adds headers to all responses. */
|
100 | headers?: {
|
101 | [key: string]: string;
|
102 | } | undefined;
|
103 | /**
|
104 | * When using the HTML5 History API, the index.html page will likely
|
105 | * have to be served in place of any 404 responses.
|
106 | */
|
107 | historyApiFallback?: boolean | connectHistoryApiFallback.Options | undefined;
|
108 | /**
|
109 | * Specify a host to use. By default this is localhost.
|
110 | */
|
111 | host?: string | undefined;
|
112 | /**
|
113 | * Enable webpack's Hot Module Replacement feature.
|
114 | * Note that webpack.HotModuleReplacementPlugin is required to fully
|
115 | * enable HMR. If webpack or webpack-dev-server are launched with the
|
116 | * --hot option, this plugin will be added automatically, so you may
|
117 | * not need to add this to your webpack.config.js.
|
118 | */
|
119 | hot?: boolean | undefined;
|
120 | /**
|
121 | * Enables Hot Module Replacement (see devServer.hot) without page
|
122 | * refresh as fallback in case of build failures.
|
123 | */
|
124 | hotOnly?: boolean | undefined;
|
125 | /**
|
126 | * Serve over HTTP/2 using spdy. This option is ignored for Node 10.0.0
|
127 | * and above, as spdy is broken for those versions. The dev server will
|
128 | * migrate over to Node's built-in HTTP/2 once Express supports it.
|
129 | */
|
130 | http2?: boolean | undefined;
|
131 | /**
|
132 | * By default dev-server will be served over HTTP. It can optionally be
|
133 | * served over HTTP/2 with HTTPS.
|
134 | */
|
135 | https?: boolean | https.ServerOptions | undefined;
|
136 | /**
|
137 | * The filename that is considered the index file.
|
138 | */
|
139 | index?: string | undefined;
|
140 | /**
|
141 | * Tells devServer to inject a client. Setting devServer.injectClient
|
142 | * to true will result in always injecting a client. It is possible to
|
143 | * provide a function to inject conditionally
|
144 | */
|
145 | injectClient?: boolean | ((compilerConfig: webpack.Compiler) => boolean) | undefined;
|
146 | /**
|
147 | * Tells devServer to inject a Hot Module Replacement. Setting
|
148 | * devServer.injectHot to true will result in always injecting. It is
|
149 | * possible to provide a function to inject conditionally
|
150 | */
|
151 | injectHot?: boolean | ((compilerConfig: webpack.Compiler) => boolean) | undefined;
|
152 | /**
|
153 | * Toggle between the dev-server's two different modes. By default the
|
154 | * application will be served with inline mode enabled. This means
|
155 | * that a script will be inserted in your bundle to take care of live
|
156 | * reloading, and build messages will appear in the browser console.
|
157 | */
|
158 | inline?: boolean | undefined;
|
159 | /**
|
160 | * When lazy is enabled, the dev-server will only compile the bundle
|
161 | * when it gets requested. This means that webpack will not watch any
|
162 | * file changes.
|
163 | */
|
164 | lazy?: boolean | undefined;
|
165 | /**
|
166 | * By default, the dev-server will reload/refresh the page when file
|
167 | * changes are detected. devServer.hot option must be disabled or
|
168 | * devServer.watchContentBase option must be enabled in order for
|
169 | * liveReload to take effect. Disable devServer.liveReload by setting
|
170 | * it to false
|
171 | */
|
172 | liveReload?: boolean | undefined;
|
173 | /**
|
174 | * The object is passed to the underlying webpack-dev-middleware. See
|
175 | * [documentation](https:
|
176 | * for usage notes.
|
177 | */
|
178 | mimeTypes?:
|
179 | | {
|
180 | [key: string]: string[];
|
181 | }
|
182 | | {
|
183 | typeMap?: {
|
184 | [key: string]: string[];
|
185 | } & {
|
186 | force: boolean;
|
187 | } | undefined;
|
188 | } | undefined;
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 | noInfo?: boolean | undefined;
|
195 | |
196 |
|
197 |
|
198 |
|
199 | onListening?: ((server: WebpackDevServer) => void) | undefined;
|
200 |
|
201 | open?: boolean | string | object | undefined;
|
202 |
|
203 | openPage?: string | string[] | undefined;
|
204 | |
205 |
|
206 |
|
207 |
|
208 | overlay?:
|
209 | | boolean
|
210 | | {
|
211 | warnings?: boolean | undefined;
|
212 | errors?: boolean | undefined;
|
213 | } | undefined;
|
214 | |
215 |
|
216 |
|
217 |
|
218 | pfx?: string | undefined;
|
219 |
|
220 | pfxPassphrase?: string | undefined;
|
221 |
|
222 | port?: number | undefined;
|
223 | |
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 | proxy?: ProxyConfigMap | ProxyConfigArray | undefined;
|
238 | |
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | public?: string | undefined;
|
245 | |
246 |
|
247 |
|
248 |
|
249 | publicPath?: string | undefined;
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 | quiet?: boolean | undefined;
|
256 | |
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 | serveIndex?: boolean | undefined;
|
263 | |
264 |
|
265 |
|
266 |
|
267 |
|
268 | setup?: ((app: express.Application, server: WebpackDevServer) => void) | undefined;
|
269 |
|
270 | socket?: string | undefined;
|
271 | |
272 |
|
273 |
|
274 | sockHost?: string | undefined;
|
275 | |
276 |
|
277 |
|
278 |
|
279 | sockPath?: string | undefined;
|
280 | |
281 |
|
282 |
|
283 | sockPort?: string | number | undefined;
|
284 | |
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | staticOptions?: serveStatic.ServeStaticOptions | undefined;
|
291 | |
292 |
|
293 |
|
294 |
|
295 |
|
296 | stats?: webpack.Configuration['stats'] | undefined;
|
297 | |
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 | transportMode?:
|
318 | | 'sockjs'
|
319 | | 'ws'
|
320 | | {
|
321 | client: object;
|
322 | server: 'ws';
|
323 | }
|
324 | | {
|
325 | client: 'ws';
|
326 | server: object;
|
327 | }
|
328 | | {
|
329 | client: object;
|
330 | server: object;
|
331 | } | undefined;
|
332 |
|
333 | useLocalIp?: boolean | undefined;
|
334 | |
335 |
|
336 |
|
337 |
|
338 |
|
339 | watchContentBase?: boolean | undefined;
|
340 |
|
341 | watchOptions?: webpack.Configuration['watchOptions'] | undefined;
|
342 |
|
343 | writeToDisk?: boolean | ((filePath: string) => boolean) | undefined;
|
344 | }
|
345 | }
|
346 |
|
347 | declare module 'webpack' {
|
348 | interface Configuration {
|
349 | |
350 |
|
351 |
|
352 |
|
353 | devServer?: WebpackDevServer.Configuration | undefined;
|
354 | }
|
355 | }
|
356 |
|
357 | declare class WebpackDevServer {
|
358 | listeningApp: WebpackDevServer.ListeningApp;
|
359 | sockets: NodeJS.EventEmitter[];
|
360 |
|
361 | constructor(webpack: webpack.Compiler | webpack.MultiCompiler, config?: WebpackDevServer.Configuration);
|
362 |
|
363 | static addDevServerEntrypoints(
|
364 | webpackOptions: webpack.Configuration | webpack.Configuration[],
|
365 | config: WebpackDevServer.Configuration,
|
366 | listeningApp?: WebpackDevServer.ListeningApp,
|
367 | ): void;
|
368 |
|
369 | listen(port: number, hostname: string, callback?: (error?: Error) => void): http.Server;
|
370 |
|
371 | listen(port: number, callback?: (error?: Error) => void): http.Server;
|
372 |
|
373 | close(callback?: () => void): void;
|
374 |
|
375 | sockWrite(sockets: NodeJS.EventEmitter[], type: string, data?: any): void;
|
376 | }
|
377 |
|
378 | export = WebpackDevServer;
|
379 |
|
\ | No newline at end of file |