webpack-dev-server 4.7.2 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -6
- package/bin/cli-flags.js +34 -22
- package/client/index.js +1 -1
- package/client/modules/sockjs-client/index.js +76 -1120
- package/client/socket.js +5 -2
- package/client/utils/createSocketURL.js +1 -1
- package/client/utils/parseURL.js +1 -1
- package/client/utils/stripAnsi.js +20 -0
- package/lib/Server.js +138 -141
- package/lib/options.json +89 -21
- package/package.json +34 -33
- package/types/bin/cli-flags.d.ts +63 -33
- package/types/lib/Server.d.ts +484 -476
- package/types/lib/servers/WebsocketServer.d.ts +1 -1
- package/client/modules/strip-ansi/index.js +0 -119
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ fast in-memory access to the webpack assets.
|
|
|
27
27
|
- [With the CLI](#with-the-cli)
|
|
28
28
|
- [With NPM Scripts](#with-npm-scripts)
|
|
29
29
|
- [With the API](#with-the-api)
|
|
30
|
+
- [With TypeScript](#with-typescript)
|
|
30
31
|
- [The Result](#the-result)
|
|
31
32
|
- [Browser Support](#browser-support)
|
|
32
33
|
- [Support](#support)
|
|
@@ -42,6 +43,18 @@ First things first, install the module:
|
|
|
42
43
|
npm install webpack-dev-server --save-dev
|
|
43
44
|
```
|
|
44
45
|
|
|
46
|
+
or
|
|
47
|
+
|
|
48
|
+
```console
|
|
49
|
+
yarn add -D webpack-dev-server
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
or
|
|
53
|
+
|
|
54
|
+
```console
|
|
55
|
+
pnpm add -D webpack-dev-server
|
|
56
|
+
```
|
|
57
|
+
|
|
45
58
|
_Note: While you can install and run webpack-dev-server globally, we recommend
|
|
46
59
|
installing it locally. webpack-dev-server will always use a local installation
|
|
47
60
|
over a global one._
|
|
@@ -90,18 +103,18 @@ Options:
|
|
|
90
103
|
you are proxying dev server, by default is 'auto').
|
|
91
104
|
--bonjour Allows to broadcasts dev server via ZeroConf networking on start.
|
|
92
105
|
--no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
|
|
93
|
-
--no-client
|
|
106
|
+
--no-client Disables client script.
|
|
94
107
|
--client-logging <value> Allows to set log level in the browser.
|
|
95
108
|
--client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
|
|
96
|
-
--no-client-overlay Disables
|
|
109
|
+
--no-client-overlay Disables the full-screen overlay in the browser when there are compiler errors or warnings.
|
|
97
110
|
--client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
|
|
98
|
-
--no-client-overlay-errors
|
|
111
|
+
--no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors.
|
|
99
112
|
--client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
|
|
100
|
-
--no-client-overlay-warnings
|
|
113
|
+
--no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings.
|
|
101
114
|
--client-progress Prints compilation progress in percentage in the browser.
|
|
102
115
|
--no-client-progress Does not print compilation progress in percentage in the browser.
|
|
103
116
|
--client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client.
|
|
104
|
-
--no-client-reconnect Tells dev-server to not to try to
|
|
117
|
+
--no-client-reconnect Tells dev-server to not to try to reconnect the client.
|
|
105
118
|
--client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
|
|
106
119
|
--client-web-socket-url <value> Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).
|
|
107
120
|
--client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
|
|
@@ -114,7 +127,7 @@ Options:
|
|
|
114
127
|
--no-compress Disables gzip compression for everything served.
|
|
115
128
|
--history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5
|
|
116
129
|
History API.
|
|
117
|
-
--no-history-api-fallback
|
|
130
|
+
--no-history-api-fallback Disallows to proxy requests through a specified index page.
|
|
118
131
|
--host <value> Allows to specify a hostname to use.
|
|
119
132
|
--hot [value] Enables Hot Module Replacement.
|
|
120
133
|
--no-hot Disables Hot Module Replacement.
|
|
@@ -237,6 +250,30 @@ While it's recommended to run webpack-dev-server via the CLI, you may also choos
|
|
|
237
250
|
|
|
238
251
|
See the related [API documentation for `webpack-dev-server`](https://webpack.js.org/api/webpack-dev-server/).
|
|
239
252
|
|
|
253
|
+
### With TypeScript
|
|
254
|
+
|
|
255
|
+
If you use TypeScript in the webpack config, you'll need to properly type `devServer` property in order to avoid TS errors (e.g. `'devServer' does not exist in type 'Configuration'`). For that use either:
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
/// <reference path="node_modules/webpack-dev-server/types/lib/Server.d.ts"/>
|
|
259
|
+
import type { Configuration } from "webpack";
|
|
260
|
+
|
|
261
|
+
// Your logic
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Or you can import the type from `webpack-dev-server`, i.e.
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
import type { Configuration as DevServerConfiguration } from "webpack-dev-server";
|
|
268
|
+
import type { Configuration } from "webpack";
|
|
269
|
+
|
|
270
|
+
const devServer: DevServerConfiguration = {};
|
|
271
|
+
const config: Configuration = { devServer };
|
|
272
|
+
|
|
273
|
+
// module.exports
|
|
274
|
+
export default config;
|
|
275
|
+
```
|
|
276
|
+
|
|
240
277
|
### The Result
|
|
241
278
|
|
|
242
279
|
Either method will start a server instance and begin listening for connections
|
package/bin/cli-flags.js
CHANGED
|
@@ -46,13 +46,13 @@ module.exports = {
|
|
|
46
46
|
multiple: false,
|
|
47
47
|
description:
|
|
48
48
|
"Allows to broadcasts dev server via ZeroConf networking on start.",
|
|
49
|
+
negatedDescription:
|
|
50
|
+
"Disallows to broadcasts dev server via ZeroConf networking on start.",
|
|
49
51
|
path: "bonjour",
|
|
50
52
|
},
|
|
51
53
|
],
|
|
52
54
|
description:
|
|
53
55
|
"Allows to broadcasts dev server via ZeroConf networking on start.",
|
|
54
|
-
negatedDescription:
|
|
55
|
-
"Disallows to broadcasts dev server via ZeroConf networking on start.",
|
|
56
56
|
simpleType: "boolean",
|
|
57
57
|
multiple: false,
|
|
58
58
|
},
|
|
@@ -61,6 +61,7 @@ module.exports = {
|
|
|
61
61
|
{
|
|
62
62
|
description:
|
|
63
63
|
"Allows to specify options for client script in the browser or disable client script.",
|
|
64
|
+
negatedDescription: "Disables client script.",
|
|
64
65
|
multiple: false,
|
|
65
66
|
path: "client",
|
|
66
67
|
type: "enum",
|
|
@@ -93,13 +94,13 @@ module.exports = {
|
|
|
93
94
|
multiple: false,
|
|
94
95
|
description:
|
|
95
96
|
"Enables a full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
97
|
+
negatedDescription:
|
|
98
|
+
"Disables the full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
96
99
|
path: "client.overlay",
|
|
97
100
|
},
|
|
98
101
|
],
|
|
99
102
|
description:
|
|
100
103
|
"Enables a full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
101
|
-
negatedDescription:
|
|
102
|
-
"Disables a full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
103
104
|
simpleType: "boolean",
|
|
104
105
|
multiple: false,
|
|
105
106
|
},
|
|
@@ -110,6 +111,8 @@ module.exports = {
|
|
|
110
111
|
multiple: false,
|
|
111
112
|
description:
|
|
112
113
|
"Enables a full-screen overlay in the browser when there are compiler errors.",
|
|
114
|
+
negatedDescription:
|
|
115
|
+
"Disables the full-screen overlay in the browser when there are compiler errors.",
|
|
113
116
|
path: "client.overlay.errors",
|
|
114
117
|
},
|
|
115
118
|
],
|
|
@@ -125,6 +128,8 @@ module.exports = {
|
|
|
125
128
|
multiple: false,
|
|
126
129
|
description:
|
|
127
130
|
"Enables a full-screen overlay in the browser when there are compiler warnings.",
|
|
131
|
+
negatedDescription:
|
|
132
|
+
"Disables the full-screen overlay in the browser when there are compiler warnings.",
|
|
128
133
|
path: "client.overlay.warnings",
|
|
129
134
|
},
|
|
130
135
|
],
|
|
@@ -140,12 +145,12 @@ module.exports = {
|
|
|
140
145
|
multiple: false,
|
|
141
146
|
description:
|
|
142
147
|
"Prints compilation progress in percentage in the browser.",
|
|
148
|
+
negatedDescription:
|
|
149
|
+
"Does not print compilation progress in percentage in the browser.",
|
|
143
150
|
path: "client.progress",
|
|
144
151
|
},
|
|
145
152
|
],
|
|
146
153
|
description: "Prints compilation progress in percentage in the browser.",
|
|
147
|
-
negatedDescription:
|
|
148
|
-
"Does not print compilation progress in percentage in the browser.",
|
|
149
154
|
simpleType: "boolean",
|
|
150
155
|
multiple: false,
|
|
151
156
|
},
|
|
@@ -156,6 +161,8 @@ module.exports = {
|
|
|
156
161
|
multiple: false,
|
|
157
162
|
description:
|
|
158
163
|
"Tells dev-server the number of times it should try to reconnect the client.",
|
|
164
|
+
negatedDescription:
|
|
165
|
+
"Tells dev-server to not to try to reconnect the client.",
|
|
159
166
|
path: "client.reconnect",
|
|
160
167
|
},
|
|
161
168
|
{
|
|
@@ -168,7 +175,6 @@ module.exports = {
|
|
|
168
175
|
],
|
|
169
176
|
description:
|
|
170
177
|
"Tells dev-server the number of times it should try to reconnect the client.",
|
|
171
|
-
negatedDescription: "Tells dev-server to not to try to connect the client.",
|
|
172
178
|
simpleType: "string",
|
|
173
179
|
multiple: false,
|
|
174
180
|
},
|
|
@@ -321,11 +327,11 @@ module.exports = {
|
|
|
321
327
|
type: "boolean",
|
|
322
328
|
multiple: false,
|
|
323
329
|
description: "Enables gzip compression for everything served.",
|
|
330
|
+
negatedDescription: "Disables gzip compression for everything served.",
|
|
324
331
|
path: "compress",
|
|
325
332
|
},
|
|
326
333
|
],
|
|
327
334
|
description: "Enables gzip compression for everything served.",
|
|
328
|
-
negatedDescription: "Disables gzip compression for everything served.",
|
|
329
335
|
simpleType: "boolean",
|
|
330
336
|
multiple: false,
|
|
331
337
|
},
|
|
@@ -336,6 +342,8 @@ module.exports = {
|
|
|
336
342
|
multiple: false,
|
|
337
343
|
description:
|
|
338
344
|
"Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5 History API.",
|
|
345
|
+
negatedDescription:
|
|
346
|
+
"Disallows to proxy requests through a specified index page.",
|
|
339
347
|
path: "historyApiFallback",
|
|
340
348
|
},
|
|
341
349
|
],
|
|
@@ -370,6 +378,7 @@ module.exports = {
|
|
|
370
378
|
type: "boolean",
|
|
371
379
|
multiple: false,
|
|
372
380
|
description: "Enables Hot Module Replacement.",
|
|
381
|
+
negatedDescription: "Disables Hot Module Replacement.",
|
|
373
382
|
path: "hot",
|
|
374
383
|
},
|
|
375
384
|
{
|
|
@@ -381,7 +390,6 @@ module.exports = {
|
|
|
381
390
|
},
|
|
382
391
|
],
|
|
383
392
|
description: "Enables Hot Module Replacement.",
|
|
384
|
-
negatedDescription: "Disables Hot Module Replacement.",
|
|
385
393
|
simpleType: "string",
|
|
386
394
|
multiple: false,
|
|
387
395
|
},
|
|
@@ -392,12 +400,12 @@ module.exports = {
|
|
|
392
400
|
multiple: false,
|
|
393
401
|
description:
|
|
394
402
|
"Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.",
|
|
403
|
+
negatedDescription: "Does not serve over HTTP/2 using SPDY.",
|
|
395
404
|
path: "http2",
|
|
396
405
|
},
|
|
397
406
|
],
|
|
398
407
|
description:
|
|
399
408
|
"Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.",
|
|
400
|
-
negatedDescription: "Does not serve over HTTP/2 using SPDY.",
|
|
401
409
|
simpleType: "boolean",
|
|
402
410
|
multiple: false,
|
|
403
411
|
},
|
|
@@ -408,13 +416,13 @@ module.exports = {
|
|
|
408
416
|
multiple: false,
|
|
409
417
|
description:
|
|
410
418
|
"Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.",
|
|
419
|
+
negatedDescription:
|
|
420
|
+
"Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).",
|
|
411
421
|
path: "https",
|
|
412
422
|
},
|
|
413
423
|
],
|
|
414
424
|
description:
|
|
415
425
|
"Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.",
|
|
416
|
-
negatedDescription:
|
|
417
|
-
"Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).",
|
|
418
426
|
simpleType: "boolean",
|
|
419
427
|
multiple: false,
|
|
420
428
|
},
|
|
@@ -620,12 +628,12 @@ module.exports = {
|
|
|
620
628
|
multiple: false,
|
|
621
629
|
description:
|
|
622
630
|
"Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.",
|
|
631
|
+
negatedDescription: "Does not request for an SSL certificate.",
|
|
623
632
|
path: "https.requestCert",
|
|
624
633
|
},
|
|
625
634
|
],
|
|
626
635
|
description:
|
|
627
636
|
"Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.",
|
|
628
|
-
negatedDescription: "Does not request for an SSL certificate.",
|
|
629
637
|
simpleType: "boolean",
|
|
630
638
|
multiple: false,
|
|
631
639
|
},
|
|
@@ -656,13 +664,13 @@ module.exports = {
|
|
|
656
664
|
multiple: false,
|
|
657
665
|
description:
|
|
658
666
|
"Enables reload/refresh the page(s) when file changes are detected (enabled by default).",
|
|
667
|
+
negatedDescription:
|
|
668
|
+
"Disables reload/refresh the page(s) when file changes are detected (enabled by default).",
|
|
659
669
|
path: "liveReload",
|
|
660
670
|
},
|
|
661
671
|
],
|
|
662
672
|
description:
|
|
663
673
|
"Enables reload/refresh the page(s) when file changes are detected (enabled by default).",
|
|
664
|
-
negatedDescription:
|
|
665
|
-
"Disables reload/refresh the page(s) when file changes are detected (enabled by default)",
|
|
666
674
|
simpleType: "boolean",
|
|
667
675
|
multiple: false,
|
|
668
676
|
},
|
|
@@ -673,13 +681,13 @@ module.exports = {
|
|
|
673
681
|
multiple: false,
|
|
674
682
|
description:
|
|
675
683
|
"Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
|
|
684
|
+
negatedDescription:
|
|
685
|
+
"Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
|
|
676
686
|
path: "magicHtml",
|
|
677
687
|
},
|
|
678
688
|
],
|
|
679
689
|
description:
|
|
680
690
|
"Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
|
|
681
|
-
negatedDescription:
|
|
682
|
-
"Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
|
|
683
691
|
simpleType: "boolean",
|
|
684
692
|
multiple: false,
|
|
685
693
|
},
|
|
@@ -697,12 +705,12 @@ module.exports = {
|
|
|
697
705
|
multiple: false,
|
|
698
706
|
description:
|
|
699
707
|
"Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).",
|
|
708
|
+
negatedDescription: "Does not open the default browser.",
|
|
700
709
|
path: "open",
|
|
701
710
|
},
|
|
702
711
|
],
|
|
703
712
|
description:
|
|
704
713
|
"Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).",
|
|
705
|
-
negatedDescription: "Does not open the default browser.",
|
|
706
714
|
simpleType: "string",
|
|
707
715
|
multiple: true,
|
|
708
716
|
},
|
|
@@ -786,7 +794,6 @@ module.exports = {
|
|
|
786
794
|
},
|
|
787
795
|
],
|
|
788
796
|
description: "Opens specified page in browser.",
|
|
789
|
-
negatedDescription: "Does not open specified page in browser.",
|
|
790
797
|
simpleType: "string",
|
|
791
798
|
multiple: true,
|
|
792
799
|
},
|
|
@@ -1023,6 +1030,7 @@ module.exports = {
|
|
|
1023
1030
|
configs: [
|
|
1024
1031
|
{
|
|
1025
1032
|
description: "Request for an SSL certificate.",
|
|
1033
|
+
negatedDescription: "Does not request for an SSL certificate.",
|
|
1026
1034
|
multiple: false,
|
|
1027
1035
|
path: "server.options.requestCert",
|
|
1028
1036
|
type: "boolean",
|
|
@@ -1060,6 +1068,8 @@ module.exports = {
|
|
|
1060
1068
|
multiple: false,
|
|
1061
1069
|
description:
|
|
1062
1070
|
"Allows to configure options for serving static files from directory (by default 'public' directory).",
|
|
1071
|
+
negatedDescription:
|
|
1072
|
+
"Disallows to configure options for serving static files from directory.",
|
|
1063
1073
|
path: "static",
|
|
1064
1074
|
},
|
|
1065
1075
|
],
|
|
@@ -1140,12 +1150,12 @@ module.exports = {
|
|
|
1140
1150
|
multiple: true,
|
|
1141
1151
|
description:
|
|
1142
1152
|
"Tells dev server to use serveIndex middleware when enabled.",
|
|
1153
|
+
negatedDescription:
|
|
1154
|
+
"Does not tell dev server to use serveIndex middleware.",
|
|
1143
1155
|
path: "static[].serveIndex",
|
|
1144
1156
|
},
|
|
1145
1157
|
],
|
|
1146
1158
|
description: "Tells dev server to use serveIndex middleware when enabled.",
|
|
1147
|
-
negatedDescription:
|
|
1148
|
-
"Does not tell dev server to use serveIndex middleware.",
|
|
1149
1159
|
simpleType: "boolean",
|
|
1150
1160
|
multiple: true,
|
|
1151
1161
|
},
|
|
@@ -1155,11 +1165,12 @@ module.exports = {
|
|
|
1155
1165
|
type: "boolean",
|
|
1156
1166
|
multiple: true,
|
|
1157
1167
|
description: "Watches for files in static content directory.",
|
|
1168
|
+
negatedDescription:
|
|
1169
|
+
"Does not watch for files in static content directory.",
|
|
1158
1170
|
path: "static[].watch",
|
|
1159
1171
|
},
|
|
1160
1172
|
],
|
|
1161
1173
|
description: "Watches for files in static content directory.",
|
|
1162
|
-
negatedDescription: "Does not watch for files in static content directory.",
|
|
1163
1174
|
simpleType: "boolean",
|
|
1164
1175
|
multiple: true,
|
|
1165
1176
|
},
|
|
@@ -1198,6 +1209,7 @@ module.exports = {
|
|
|
1198
1209
|
{
|
|
1199
1210
|
description:
|
|
1200
1211
|
"Deprecated: please use '--web-socket-server-type' option.",
|
|
1212
|
+
negatedDescription: "Disallows to set web socket server and options.",
|
|
1201
1213
|
multiple: false,
|
|
1202
1214
|
path: "webSocketServer",
|
|
1203
1215
|
type: "enum",
|
package/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* global __resourceQuery, __webpack_hash__ */
|
|
2
2
|
/// <reference types="webpack/module" />
|
|
3
3
|
import webpackHotLog from "webpack/hot/log.js";
|
|
4
|
-
import stripAnsi from "./
|
|
4
|
+
import stripAnsi from "./utils/stripAnsi.js";
|
|
5
5
|
import parseURL from "./utils/parseURL.js";
|
|
6
6
|
import socket from "./socket.js";
|
|
7
7
|
import { formatProblem, show, hide } from "./overlay.js";
|