webpack-dev-server 4.7.4 → 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 +13 -5
- 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 +13 -7
- package/lib/options.json +52 -31
- package/package.json +29 -29
- package/types/bin/cli-flags.d.ts +36 -14
- package/types/lib/Server.d.ts +391 -583
- 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
|
@@ -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",
|
|
@@ -94,7 +95,7 @@ module.exports = {
|
|
|
94
95
|
description:
|
|
95
96
|
"Enables a full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
96
97
|
negatedDescription:
|
|
97
|
-
"Disables
|
|
98
|
+
"Disables the full-screen overlay in the browser when there are compiler errors or warnings.",
|
|
98
99
|
path: "client.overlay",
|
|
99
100
|
},
|
|
100
101
|
],
|
|
@@ -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
|
],
|
|
@@ -157,7 +162,7 @@ module.exports = {
|
|
|
157
162
|
description:
|
|
158
163
|
"Tells dev-server the number of times it should try to reconnect the client.",
|
|
159
164
|
negatedDescription:
|
|
160
|
-
"Tells dev-server to not to try to
|
|
165
|
+
"Tells dev-server to not to try to reconnect the client.",
|
|
161
166
|
path: "client.reconnect",
|
|
162
167
|
},
|
|
163
168
|
{
|
|
@@ -165,8 +170,6 @@ module.exports = {
|
|
|
165
170
|
multiple: false,
|
|
166
171
|
description:
|
|
167
172
|
"Tells dev-server the number of times it should try to reconnect the client.",
|
|
168
|
-
negatedDescription:
|
|
169
|
-
"Tells dev-server to not to try to connect the client.",
|
|
170
173
|
path: "client.reconnect",
|
|
171
174
|
},
|
|
172
175
|
],
|
|
@@ -339,6 +342,8 @@ module.exports = {
|
|
|
339
342
|
multiple: false,
|
|
340
343
|
description:
|
|
341
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.",
|
|
342
347
|
path: "historyApiFallback",
|
|
343
348
|
},
|
|
344
349
|
],
|
|
@@ -381,7 +386,6 @@ module.exports = {
|
|
|
381
386
|
values: ["only"],
|
|
382
387
|
multiple: false,
|
|
383
388
|
description: "Enables Hot Module Replacement.",
|
|
384
|
-
negatedDescription: "Disables Hot Module Replacement.",
|
|
385
389
|
path: "hot",
|
|
386
390
|
},
|
|
387
391
|
],
|
|
@@ -1026,6 +1030,7 @@ module.exports = {
|
|
|
1026
1030
|
configs: [
|
|
1027
1031
|
{
|
|
1028
1032
|
description: "Request for an SSL certificate.",
|
|
1033
|
+
negatedDescription: "Does not request for an SSL certificate.",
|
|
1029
1034
|
multiple: false,
|
|
1030
1035
|
path: "server.options.requestCert",
|
|
1031
1036
|
type: "boolean",
|
|
@@ -1063,6 +1068,8 @@ module.exports = {
|
|
|
1063
1068
|
multiple: false,
|
|
1064
1069
|
description:
|
|
1065
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.",
|
|
1066
1073
|
path: "static",
|
|
1067
1074
|
},
|
|
1068
1075
|
],
|
|
@@ -1202,6 +1209,7 @@ module.exports = {
|
|
|
1202
1209
|
{
|
|
1203
1210
|
description:
|
|
1204
1211
|
"Deprecated: please use '--web-socket-server-type' option.",
|
|
1212
|
+
negatedDescription: "Disallows to set web socket server and options.",
|
|
1205
1213
|
multiple: false,
|
|
1206
1214
|
path: "webSocketServer",
|
|
1207
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";
|