webpack-dev-server 4.7.4 → 4.9.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 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._
@@ -67,137 +80,127 @@ Usage: webpack serve|server|s [entries...] [options]
67
80
  Run the webpack dev server.
68
81
 
69
82
  Options:
70
- -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
71
- --config-name <value...> Name of the configuration to use.
72
- -m, --merge Merge two or more configurations using 'webpack-merge'.
73
- --env <value...> Environment passed to the configuration when it is a function.
74
- --node-env <value> Sets process.env.NODE_ENV to the specified value.
75
- --progress [value] Print compilation progress during build.
76
- -j, --json [value] Prints result as JSON or store it in a file.
77
- --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
78
- -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
79
- -t, --target <value> Sets the build target e.g. node.
80
- -d, --devtool <value> Determine source maps to use.
81
- --no-devtool Do not generate source maps.
82
- --mode <value> Defines the mode to pass to webpack.
83
- --name <value> Name of the configuration. Used when loading multiple configurations.
84
- --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
85
- --no-stats Disable stats output.
86
- --watch-options-stdin Stop watching when stdin stream has ended.
87
- --no-watch-options-stdin Do not stop watching when stdin stream has ended.
88
- --allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
89
- --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when
90
- you are proxying dev server, by default is 'auto').
91
- --bonjour Allows to broadcasts dev server via ZeroConf networking on start.
92
- --no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
93
- --no-client Negative 'client' option.
94
- --client-logging <value> Allows to set log level in the browser.
95
- --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
96
- --no-client-overlay Disables a full-screen overlay in the browser when there are compiler errors or warnings.
97
- --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
98
- --no-client-overlay-errors Negative 'client-overlay-errors' option.
99
- --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
100
- --no-client-overlay-warnings Negative 'client-overlay-warnings' option.
101
- --client-progress Prints compilation progress in percentage in the browser.
102
- --no-client-progress Does not print compilation progress in percentage in the browser.
103
- --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 connect the client.
105
- --client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
106
- --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
- --client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
108
- --client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
109
- --client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.
110
- --client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
111
- --client-web-socket-url-protocol <value> Tells clients connected to devServer to use the provided protocol.
112
- --client-web-socket-url-username <value> Tells clients connected to devServer to use the provided username to authenticate.
113
- --compress Enables gzip compression for everything served.
114
- --no-compress Disables gzip compression for everything served.
115
- --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
- History API.
117
- --no-history-api-fallback Negative 'history-api-fallback' option.
118
- --host <value> Allows to specify a hostname to use.
119
- --hot [value] Enables Hot Module Replacement.
120
- --no-hot Disables Hot Module Replacement.
121
- --http2 Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.
122
- --no-http2 Does not serve over HTTP/2 using SPDY.
123
- --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.
124
- --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
125
- --https-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
126
- --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the
127
- `server.options.ca` option.
128
- --https-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
129
- --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the
130
- `server.options.ca` option.
131
- --https-cert <value...> Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
132
- --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, use the
133
- `server.options.cert` option.
134
- --https-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the
135
- `server.options.crl` option.
136
- --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs
137
- (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
138
- --https-key <value...> Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
139
- --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
140
- --https-passphrase <value> Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option.
141
- --https-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
142
- --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the
143
- `server.options.pfx` option.
144
- --https-request-cert Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.
145
- --no-https-request-cert Does not request for an SSL certificate.
146
- --ipc [value] Listen to a unix socket.
147
- --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
148
- --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default)
149
- --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
150
- --no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
151
- --open [value...] 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).
152
- --no-open Does not open the default browser.
153
- --open-app <value...> Open specified browser. Deprecated: please use '--open-app-name'.
154
- --open-app-name <value...> Open specified browser.
155
- --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
156
- --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started
157
- (set it to true to open your default browser).
158
- --open-target <value...> Opens specified page in browser.
159
- --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
160
- --port <value> Allows to specify a port to use.
161
- --server-options-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate.
162
- --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.
163
- --server-options-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
164
- --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated,
165
- use the `server.options.ca` option.
166
- --server-options-cert <value...> Path to an SSL certificate or content of an SSL certificate.
167
- --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.
168
- --server-options-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
169
- --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM
170
- formatted CRLs (Certificate Revocation Lists).
171
- --server-options-key <value...> Path to an SSL key or content of an SSL key.
172
- --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.
173
- --server-options-passphrase <value> Passphrase for a pfx file.
174
- --server-options-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file.
175
- --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.
176
- --server-options-request-cert Request for an SSL certificate.
177
- --no-server-options-request-cert Negative 'server-options-request-cert' option.
178
- --server-type <value> Allows to set server and options (by default 'http').
179
- --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
180
- --no-static Negative 'static' option.
181
- --static-directory <value...> Directory for static contents.
182
- --static-public-path <value...> The static files will be available in the browser under this public path.
183
- --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
184
- --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public'
185
- directory).
186
- --static-serve-index Tells dev server to use serveIndex middleware when enabled.
187
- --no-static-serve-index Does not tell dev server to use serveIndex middleware.
188
- --static-watch Watches for files in static content directory.
189
- --no-static-watch Does not watch for files in static content directory.
190
- --watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
191
- --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
192
- --web-socket-server <value> Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').
193
- --no-web-socket-server Negative 'web-socket-server' option.
194
- --web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
83
+ -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
84
+ --config-name <value...> Name of the configuration to use.
85
+ -m, --merge Merge two or more configurations using 'webpack-merge'.
86
+ --env <value...> Environment passed to the configuration when it is a function.
87
+ --node-env <value> Sets process.env.NODE_ENV to the specified value.
88
+ --progress [value] Print compilation progress during build.
89
+ -j, --json [value] Prints result as JSON or store it in a file.
90
+ -d, --devtool <value> Determine source maps to use.
91
+ --no-devtool Do not generate source maps.
92
+ --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
93
+ --mode <value> Defines the mode to pass to webpack.
94
+ --name <value> Name of the configuration. Used when loading multiple configurations.
95
+ -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
96
+ --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
97
+ --no-stats Disable stats output.
98
+ -t, --target <value...> Sets the build target e.g. node.
99
+ --no-target Negative 'target' option.
100
+ --watch-options-stdin Stop watching when stdin stream has ended.
101
+ --no-watch-options-stdin Do not stop watching when stdin stream has ended.
102
+ --allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
103
+ --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
104
+ --bonjour Allows to broadcasts dev server via ZeroConf networking on start.
105
+ --no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
106
+ --no-client Disables client script.
107
+ --client-logging <value> Allows to set log level in the browser.
108
+ --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
109
+ --no-client-overlay Disables the full-screen overlay in the browser when there are compiler errors or warnings.
110
+ --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
111
+ --no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors.
112
+ --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
113
+ --no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings.
114
+ --client-overlay-trusted-types-policy-name <value> The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.
115
+ --client-progress Prints compilation progress in percentage in the browser.
116
+ --no-client-progress Does not print compilation progress in percentage in the browser.
117
+ --client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client.
118
+ --no-client-reconnect Tells dev-server to not to try to reconnect the client.
119
+ --client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
120
+ --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).
121
+ --client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
122
+ --client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.
123
+ --client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
124
+ --client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
125
+ --client-web-socket-url-protocol <value> Tells clients connected to devServer to use the provided protocol.
126
+ --client-web-socket-url-username <value> Tells clients connected to devServer to use the provided username to authenticate.
127
+ --compress Enables gzip compression for everything served.
128
+ --no-compress Disables gzip compression for everything served.
129
+ --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 History API.
130
+ --no-history-api-fallback Disallows to proxy requests through a specified index page.
131
+ --host <value> Allows to specify a hostname to use.
132
+ --hot [value] Enables Hot Module Replacement.
133
+ --no-hot Disables Hot Module Replacement.
134
+ --http2 Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.
135
+ --no-http2 Does not serve over HTTP/2 using SPDY.
136
+ --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.
137
+ --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
138
+ --https-passphrase <value> Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option.
139
+ --https-request-cert Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.
140
+ --no-https-request-cert Does not request for an SSL certificate.
141
+ --https-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
142
+ --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
143
+ --https-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
144
+ --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
145
+ --https-cert <value...> Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
146
+ --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
147
+ --https-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
148
+ --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
149
+ --https-key <value...> Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
150
+ --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
151
+ --https-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
152
+ --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
153
+ --ipc [value] Listen to a unix socket.
154
+ --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
155
+ --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default).
156
+ --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
157
+ --no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
158
+ --open [value...] 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).
159
+ --no-open Does not open the default browser.
160
+ --open-target <value...> Opens specified page in browser.
161
+ --open-app-name <value...> Open specified browser.
162
+ --open-app <value...> Open specified browser. Deprecated: please use '--open-app-name'.
163
+ --open-reset Clear all items provided in 'open' configuration. 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).
164
+ --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
165
+ --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
166
+ --port <value> Allows to specify a port to use.
167
+ --server-type <value> Allows to set server and options (by default 'http').
168
+ --server-options-passphrase <value> Passphrase for a pfx file.
169
+ --server-options-request-cert Request for an SSL certificate.
170
+ --no-server-options-request-cert Does not request for an SSL certificate.
171
+ --server-options-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate.
172
+ --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.
173
+ --server-options-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
174
+ --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
175
+ --server-options-cert <value...> Path to an SSL certificate or content of an SSL certificate.
176
+ --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.
177
+ --server-options-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
178
+ --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
179
+ --server-options-key <value...> Path to an SSL key or content of an SSL key.
180
+ --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.
181
+ --server-options-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file.
182
+ --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.
183
+ --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
184
+ --no-static Disallows to configure options for serving static files from directory.
185
+ --static-directory <value...> Directory for static contents.
186
+ --static-public-path <value...> The static files will be available in the browser under this public path.
187
+ --static-serve-index Tells dev server to use serveIndex middleware when enabled.
188
+ --no-static-serve-index Does not tell dev server to use serveIndex middleware.
189
+ --static-watch Watches for files in static content directory.
190
+ --no-static-watch Does not watch for files in static content directory.
191
+ --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public' directory).
192
+ --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
193
+ --watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
194
+ --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
195
+ --web-socket-server <value> Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').
196
+ --no-web-socket-server Disallows to set web socket server and options.
197
+ --web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
195
198
 
196
199
  Global options:
197
- --color Enable colors on console.
198
- --no-color Disable colors on console.
199
- -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
200
- -h, --help [verbose] Display help for commands and options.
200
+ --color Enable colors on console.
201
+ --no-color Disable colors on console.
202
+ -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
203
+ -h, --help [verbose] Display help for commands and options.
201
204
 
202
205
  To see list of all supported commands and options run 'webpack --help=verbose'.
203
206
 
@@ -228,7 +231,7 @@ And run the following in your terminal/console:
228
231
  npm run serve
229
232
  ```
230
233
 
231
- NPM will automagically reference the binary in `node_modules` for you, and
234
+ NPM will automatically refer to the the binary in `node_modules` for you, and
232
235
  execute the file or command.
233
236
 
234
237
  ### With the API
@@ -237,6 +240,30 @@ While it's recommended to run webpack-dev-server via the CLI, you may also choos
237
240
 
238
241
  See the related [API documentation for `webpack-dev-server`](https://webpack.js.org/api/webpack-dev-server/).
239
242
 
243
+ ### With TypeScript
244
+
245
+ 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:
246
+
247
+ ```ts
248
+ /// <reference path="node_modules/webpack-dev-server/types/lib/Server.d.ts"/>
249
+ import type { Configuration } from "webpack";
250
+
251
+ // Your logic
252
+ ```
253
+
254
+ Or you can import the type from `webpack-dev-server`, i.e.
255
+
256
+ ```ts
257
+ import type { Configuration as DevServerConfiguration } from "webpack-dev-server";
258
+ import type { Configuration } from "webpack";
259
+
260
+ const devServer: DevServerConfiguration = {};
261
+ const config: Configuration = { devServer };
262
+
263
+ // module.exports
264
+ export default config;
265
+ ```
266
+
240
267
  ### The Result
241
268
 
242
269
  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 a full-screen overlay in the browser when there are compiler errors or warnings.",
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
  ],
@@ -118,6 +121,21 @@ module.exports = {
118
121
  simpleType: "boolean",
119
122
  multiple: false,
120
123
  },
124
+ "client-overlay-trusted-types-policy-name": {
125
+ configs: [
126
+ {
127
+ description:
128
+ "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.",
129
+ multiple: false,
130
+ path: "client.overlay.trustedTypesPolicyName",
131
+ type: "string",
132
+ },
133
+ ],
134
+ description:
135
+ "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.",
136
+ multiple: false,
137
+ simpleType: "string",
138
+ },
121
139
  "client-overlay-warnings": {
122
140
  configs: [
123
141
  {
@@ -125,6 +143,8 @@ module.exports = {
125
143
  multiple: false,
126
144
  description:
127
145
  "Enables a full-screen overlay in the browser when there are compiler warnings.",
146
+ negatedDescription:
147
+ "Disables the full-screen overlay in the browser when there are compiler warnings.",
128
148
  path: "client.overlay.warnings",
129
149
  },
130
150
  ],
@@ -157,7 +177,7 @@ module.exports = {
157
177
  description:
158
178
  "Tells dev-server the number of times it should try to reconnect the client.",
159
179
  negatedDescription:
160
- "Tells dev-server to not to try to connect the client.",
180
+ "Tells dev-server to not to try to reconnect the client.",
161
181
  path: "client.reconnect",
162
182
  },
163
183
  {
@@ -165,8 +185,6 @@ module.exports = {
165
185
  multiple: false,
166
186
  description:
167
187
  "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
188
  path: "client.reconnect",
171
189
  },
172
190
  ],
@@ -339,6 +357,8 @@ module.exports = {
339
357
  multiple: false,
340
358
  description:
341
359
  "Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5 History API.",
360
+ negatedDescription:
361
+ "Disallows to proxy requests through a specified index page.",
342
362
  path: "historyApiFallback",
343
363
  },
344
364
  ],
@@ -381,7 +401,6 @@ module.exports = {
381
401
  values: ["only"],
382
402
  multiple: false,
383
403
  description: "Enables Hot Module Replacement.",
384
- negatedDescription: "Disables Hot Module Replacement.",
385
404
  path: "hot",
386
405
  },
387
406
  ],
@@ -1026,6 +1045,7 @@ module.exports = {
1026
1045
  configs: [
1027
1046
  {
1028
1047
  description: "Request for an SSL certificate.",
1048
+ negatedDescription: "Does not request for an SSL certificate.",
1029
1049
  multiple: false,
1030
1050
  path: "server.options.requestCert",
1031
1051
  type: "boolean",
@@ -1063,6 +1083,8 @@ module.exports = {
1063
1083
  multiple: false,
1064
1084
  description:
1065
1085
  "Allows to configure options for serving static files from directory (by default 'public' directory).",
1086
+ negatedDescription:
1087
+ "Disallows to configure options for serving static files from directory.",
1066
1088
  path: "static",
1067
1089
  },
1068
1090
  ],
@@ -1202,6 +1224,7 @@ module.exports = {
1202
1224
  {
1203
1225
  description:
1204
1226
  "Deprecated: please use '--web-socket-server-type' option.",
1227
+ negatedDescription: "Disallows to set web socket server and options.",
1205
1228
  multiple: false,
1206
1229
  path: "webSocketServer",
1207
1230
  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 "./modules/strip-ansi/index.js";
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";
@@ -14,7 +14,7 @@ import createSocketURL from "./utils/createSocketURL.js";
14
14
  * @property {boolean} hot
15
15
  * @property {boolean} liveReload
16
16
  * @property {boolean} progress
17
- * @property {boolean | { warnings?: boolean, errors?: boolean }} overlay
17
+ * @property {boolean | { warnings?: boolean, errors?: boolean, trustedTypesPolicyName?: string }} overlay
18
18
  * @property {string} [logging]
19
19
  * @property {number} [reconnect]
20
20
  */
@@ -216,7 +216,8 @@ var onSocketMessage = {
216
216
  var needShowOverlayForWarnings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings;
217
217
 
218
218
  if (needShowOverlayForWarnings) {
219
- show("warning", _warnings);
219
+ var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
220
+ show("warning", _warnings, trustedTypesPolicyName || null);
220
221
  }
221
222
 
222
223
  if (params && params.preventReloading) {
@@ -249,7 +250,8 @@ var onSocketMessage = {
249
250
  var needShowOverlayForErrors = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors;
250
251
 
251
252
  if (needShowOverlayForErrors) {
252
- show("error", _errors);
253
+ var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
254
+ show("error", _errors, trustedTypesPolicyName || null);
253
255
  }
254
256
  },
255
257