webpack-dev-server 4.0.0-beta.2 → 4.0.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.
Files changed (52) hide show
  1. package/README.md +109 -58
  2. package/bin/cli-flags.js +827 -269
  3. package/bin/process-arguments.js +332 -0
  4. package/bin/webpack-dev-server.js +46 -30
  5. package/client/clients/SockJSClient.js +11 -44
  6. package/client/clients/WebSocketClient.js +43 -0
  7. package/client/index.js +90 -98
  8. package/client/modules/logger/index.js +90 -2736
  9. package/client/modules/sockjs-client/index.js +127 -41
  10. package/client/modules/strip-ansi/index.js +69 -37
  11. package/client/overlay.js +111 -95
  12. package/client/socket.js +11 -12
  13. package/client/utils/createSocketURL.js +70 -0
  14. package/client/utils/getCurrentScriptSource.js +10 -9
  15. package/client/utils/log.js +5 -10
  16. package/client/utils/parseURL.js +43 -0
  17. package/client/utils/reloadApp.js +49 -36
  18. package/client/utils/sendMessage.js +3 -5
  19. package/lib/Server.js +1456 -539
  20. package/lib/options.json +562 -314
  21. package/lib/servers/BaseServer.js +2 -1
  22. package/lib/servers/SockJSServer.js +32 -31
  23. package/lib/servers/WebsocketServer.js +42 -41
  24. package/lib/utils/DevServerPlugin.js +275 -128
  25. package/package.json +51 -52
  26. package/CHANGELOG.md +0 -569
  27. package/client/clients/BaseClient.js +0 -23
  28. package/client/clients/WebsocketClient.js +0 -76
  29. package/client/modules/logger/SyncBailHookFake.js +0 -10
  30. package/client/utils/createSocketUrl.js +0 -94
  31. package/client/webpack.config.js +0 -57
  32. package/lib/utils/colors.js +0 -22
  33. package/lib/utils/createCertificate.js +0 -69
  34. package/lib/utils/createDomain.js +0 -31
  35. package/lib/utils/defaultPort.js +0 -3
  36. package/lib/utils/defaultTo.js +0 -7
  37. package/lib/utils/findPort.js +0 -39
  38. package/lib/utils/getCertificate.js +0 -50
  39. package/lib/utils/getColorsOption.js +0 -15
  40. package/lib/utils/getCompilerConfigArray.js +0 -8
  41. package/lib/utils/getSocketClientPath.d.ts +0 -3
  42. package/lib/utils/getSocketClientPath.js +0 -38
  43. package/lib/utils/getSocketServerImplementation.js +0 -42
  44. package/lib/utils/getStatsOption.js +0 -16
  45. package/lib/utils/getVersions.js +0 -10
  46. package/lib/utils/normalizeOptions.js +0 -122
  47. package/lib/utils/routes.js +0 -70
  48. package/lib/utils/runBonjour.js +0 -21
  49. package/lib/utils/runOpen.js +0 -83
  50. package/lib/utils/setupExitSignals.js +0 -25
  51. package/lib/utils/tryParseInt.js +0 -13
  52. package/lib/utils/updateCompiler.js +0 -14
package/README.md CHANGED
@@ -55,72 +55,123 @@ The easiest way to use it is with the [webpack CLI](https://webpack.js.org/api/c
55
55
  `webpack.config.js` is, run:
56
56
 
57
57
  ```console
58
- node_modules/.bin/webpack serve
58
+ npx webpack serve
59
59
  ```
60
60
 
61
61
  Following options are available with `webpack serve`:
62
62
 
63
63
  ```
64
- Usage: webpack serve|s [entries...] [options]
64
+ Usage: webpack serve|server|s [entries...] [options]
65
+
66
+ Run the webpack dev server.
65
67
 
66
68
  Options:
67
- -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
68
- --config-name <value...> Name of the configuration to use.
69
- -m, --merge Merge two or more configurations using 'webpack-merge'.
70
- --env <value...> Environment passed to the configuration when it is a function.
71
- --node-env <value> Sets process.env.NODE_ENV to the specified value.
72
- --progress [value] Print compilation progress during build.
73
- -j, --json [value] Prints result as JSON or store it in a file.
74
- -d, --devtool <value> Determine source maps to use.
75
- --no-devtool Do not generate source maps.
76
- --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
77
- --mode <value> Defines the mode to pass to webpack.
78
- --name <value> Name of the configuration. Used when loading multiple configurations.
79
- -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
80
- --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
81
- --no-stats Disable stats output.
82
- -t, --target <value...> Sets the build target e.g. node.
83
- --no-target Negative 'target' option.
84
- --watch-options-stdin Stop watching when stdin stream has ended.
85
- --no-watch-options-stdin Do not stop watching when stdin stream has ended.
86
- --host <value> The hostname/ip address the server will bind to.
87
- --port <value> The port server will listen to.
88
- --static [value...] A directory to serve static content from.
89
- --no-static Negative 'static' option.
90
- --live-reload Enables live reloading on changing files.
91
- --no-live-reload Disables live reloading on changing files.
92
- --https Use HTTPS protocol.
93
- --no-https Do not use HTTPS protocol.
94
- --http2 Use HTTP/2, must be used with HTTPS.
95
- --no-http2 Do not use HTTP/2.
96
- --bonjour Broadcasts the server via ZeroConf networking on start.
97
- --no-bonjour Do not broadcast the server via ZeroConf networking on start.
98
- --client-progress Print compilation progress in percentage in the browser.
99
- --no-client-progress Do not print compilation progress in percentage in the browser.
100
- --client-overlay Show a full-screen overlay in the browser when there are compiler errors or warnings.
101
- --no-client-overlay Do not show a full-screen overlay in the browser when there are compiler errors or warnings.
102
- --setup-exit-signals Close and exit the process on SIGINT and SIGTERM.
103
- --no-setup-exit-signals Do not close and exit the process on SIGNIT and SIGTERM.
104
- --open [value...] Open the default browser.
105
- --no-open Do not open the default browser.
106
- --open-app <value> Open specified browser.
107
- --open-target [value...] Open specified route in browser.
108
- --no-open-target Do not open specified route in browser.
109
- --client-logging <value> Log level in the browser (none, error, warn, info, log, verbose).
110
- --history-api-fallback Fallback to /index.html for Single Page Applications.
111
- --no-history-api-fallback Do not fallback to /index.html for Single Page Applications.
112
- --compress Enable gzip compression.
113
- --no-compress Disable gzip compression.
114
- --public <value> The public hostname/ip address of the server.
115
- --firewall [value...] Enable firewall or set hosts that are allowed to access the dev server.
116
- --no-firewall Disable firewall.
117
- --watch-files <value...> Watch static files for file changes.
69
+ -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
70
+ --config-name <value...> Name of the configuration to use.
71
+ -m, --merge Merge two or more configurations using 'webpack-merge'.
72
+ --env <value...> Environment passed to the configuration when it is a function.
73
+ --node-env <value> Sets process.env.NODE_ENV to the specified value.
74
+ --progress [value] Print compilation progress during build.
75
+ -j, --json [value] Prints result as JSON or store it in a file.
76
+ -d, --devtool <value> Determine source maps to use.
77
+ --no-devtool Do not generate source maps.
78
+ --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
79
+ --mode <value> Defines the mode to pass to webpack.
80
+ --name <value> Name of the configuration. Used when loading multiple configurations.
81
+ -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
82
+ --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
83
+ --no-stats Disable stats output.
84
+ -t, --target <value...> Sets the build target e.g. node.
85
+ --no-target Negative 'target' option.
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
89
+ dev server, by default is 'auto').
90
+ --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to
91
+ the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
92
+ --bonjour Allows to broadcasts dev server via ZeroConf networking on start.
93
+ --no-bonjour Negative 'bonjour' option.
94
+ --no-client Negative 'client' option.
95
+ --client-logging <value> Allows to specify options for client script in the browser or disable client script.
96
+ --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
97
+ --no-client-overlay Negative 'client-overlay' option.
98
+ --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
99
+ --no-client-overlay-errors Negative 'client-overlay-errors' option.
100
+ --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
101
+ --no-client-overlay-warnings Negative 'client-overlay-warnings' option.
102
+ --client-progress Prints compilation progress in percentage in the browser.
103
+ --no-client-progress Negative 'client-progress' option.
104
+ --client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
105
+ --client-web-socket-url <value> Allows to specify URL to web socket server (useful when you're proxying dev server and client script does
106
+ 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-pathname <value> Tells clients connected to devServer to use the provided path to connect.
109
+ --client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
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 Negative 'compress' option.
115
+ --history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page
116
+ Applications that utilise the HTML5 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 Negative 'hot' option.
121
+ --http2 Allows to serve over HTTP/2 using SPDY.
122
+ --no-http2 Negative 'http2' option.
123
+ --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
124
+ --no-https Negative 'https' option.
125
+ --https-passphrase <value> Passphrase for a pfx file.
126
+ --https-request-cert Request for an SSL certificate.
127
+ --no-https-request-cert Negative 'https-request-cert' option.
128
+ --https-cacert <value> Path to an SSL CA certificate.
129
+ --https-key <value> Path to an SSL key.
130
+ --https-pfx <value> Path to an SSL pfx file.
131
+ --https-cert <value> Path to an SSL certificate.
132
+ --ipc [value] Listen to a unix socket.
133
+ --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
134
+ --no-live-reload Negative 'live-reload' option.
135
+ --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to
136
+ true to open your default browser).
137
+ --no-open Negative 'open' option.
138
+ --open-target <value...> Opens specified page in browser.
139
+ --open-app-name <value...> Open specified browser.
140
+ --open-app <value...> Open specified browser.
141
+ --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and
142
+ page(s) after server had been started (set it to true to open your default browser).
143
+ --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
144
+ --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
145
+ --port <value> Allows to specify a port to use.
146
+ --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
147
+ --no-static Negative 'static' option.
148
+ --static-directory <value...> Directory for static contents.
149
+ --static-public-path <value...> The static files will be available in the browser under this public path.
150
+ --static-serve-index Tells dev server to use serveIndex middleware when enabled.
151
+ --no-static-serve-index Negative 'static-serve-index' option.
152
+ --static-watch Watches for files in static content directory.
153
+ --no-static-watch Negative 'static-watch' option.
154
+ --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files
155
+ from directory (by default 'public' directory).
156
+ --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the
157
+ browser under this public path.
158
+ --watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
159
+ --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files
160
+ to watch for file changes.
161
+ --web-socket-server <value> Allows to set web socket server and options (by default 'ws').
162
+ --no-web-socket-server Negative 'web-socket-server' option.
118
163
 
119
164
  Global options:
120
- --color Enable colors on console.
121
- --no-color Disable colors on console.
122
- -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
123
- -h, --help [verbose] Display help for commands and options.
165
+ --color Enable colors on console.
166
+ --no-color Disable colors on console.
167
+ -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
168
+ -h, --help [verbose] Display help for commands and options.
169
+
170
+ To see list of all supported commands and options run 'webpack --help=verbose'.
171
+
172
+ Webpack documentation: https://webpack.js.org/.
173
+ CLI documentation: https://webpack.js.org/api/cli/.
174
+ Made with ♥ by the webpack team.
124
175
  ```
125
176
 
126
177
  _**Note**: For more information on above options explore this [link](https://webpack.js.org/configuration/dev-server/)._
@@ -142,7 +193,7 @@ script as such:
142
193
  And run the following in your terminal/console:
143
194
 
144
195
  ```console
145
- npm run start:dev
196
+ npm run serve
146
197
  ```
147
198
 
148
199
  NPM will automagically reference the binary in `node_modules` for you, and