webpack-dev-server 4.0.0-beta.2 → 4.0.0-beta.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [4.0.0-beta.3](https://github.com/webpack/webpack-dev-server/compare/v4.0.0-beta.2...v4.0.0-beta.3) (2021-05-06)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * the `https.ca` option was removed in favor the `https.cacert` option
11
+ * the `dev` option was renamed to `devMiddleware`
12
+ * the `client.overlay` option is `true` by default and show warnings by default
13
+ * use server port for websocket connection by default, if you proxied `webpack-dev-server`, please update `webpack-cli` to `v4.7.0` ([#3185](https://github.com/webpack/webpack-dev-server/issues/3185)) ([0c3f817](https://github.com/webpack/webpack-dev-server/commit/0c3f8178bc80d7272246fe810964561ae747ec49))
14
+ * minimum supported Node.js version is `12.13.0`
15
+
16
+ ### Features
17
+
18
+ * added `https.cacert` ([#3240](https://github.com/webpack/webpack-dev-server/issues/3240)) ([b212a2c](https://github.com/webpack/webpack-dev-server/commit/b212a2ce73c3e58f3450708801c8b413ca65fb5b))
19
+ * added more CLI options, please run `webpack server --help` to look at them ([#3238](https://github.com/webpack/webpack-dev-server/issues/3238)) ([469e558](https://github.com/webpack/webpack-dev-server/commit/469e558d1d772006a1057954331ccecd34dfdefa))
20
+ * support `bonjour` options ([#3202](https://github.com/webpack/webpack-dev-server/issues/3202)) ([5534583](https://github.com/webpack/webpack-dev-server/commit/55345836c2d8e22e45c2150a8f003019d8a0bd56))
21
+
22
+ ### Bug Fixes
23
+
24
+ * improve warning message for `open` ([#3191](https://github.com/webpack/webpack-dev-server/issues/3191)) ([d473fd9](https://github.com/webpack/webpack-dev-server/commit/d473fd9a55334efd8d349aa2b37c64b395dea025))
25
+ * respect the `client.logging` option for HMR logging ([#3159](https://github.com/webpack/webpack-dev-server/issues/3159)) ([6f3c6ba](https://github.com/webpack/webpack-dev-server/commit/6f3c6bacb1b7f6eae95e5b688dc22b5a42628360))
26
+ * respect `client.needClientEntry` and `client.needHotEntry` options ([#3178](https://github.com/webpack/webpack-dev-server/issues/3178)) ([a2b6db9](https://github.com/webpack/webpack-dev-server/commit/a2b6db9417eb289a488584e8b244fcedc416ac56))
27
+ * overlay with warnings ([#3215](https://github.com/webpack/webpack-dev-server/issues/3215)) ([7e18161](https://github.com/webpack/webpack-dev-server/commit/7e181618ba7a8ce995bf39ded00a789a9714a14b))
28
+ * help description for options
29
+ * error description for options
30
+ * improve warning message for the `open` option
31
+
5
32
  ## [4.0.0-beta.2](https://github.com/webpack/webpack-dev-server/compare/v4.0.0-beta.1...v4.0.0-beta.2) (2021-04-06)
6
33
 
7
34
 
package/README.md CHANGED
@@ -55,7 +55,7 @@ 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`:
@@ -64,63 +64,74 @@ Following options are available with `webpack serve`:
64
64
  Usage: webpack serve|s [entries...] [options]
65
65
 
66
66
  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.
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
+ --static-directory <value> Directory for static contents.
91
+ --static-public-path <value...> The bundled files will be available in the browser under this path.
92
+ --static-serve-index Tells dev-server to use serveIndex middleware.
93
+ --no-static-serve-index Do not tell dev-server to use serveIndex middleware.
94
+ --static-watch Watch for files in static content directory.
95
+ --no-static-watch Do not watch for files in static content directory.
96
+ --live-reload Enables live reloading on changing files.
97
+ --no-live-reload Disables live reloading on changing files.
98
+ --https Use HTTPS protocol.
99
+ --no-https Do not use HTTPS protocol.
100
+ --https-passphrase <value> Passphrase for a pfx file.
101
+ --https-key <value> Path to an SSL key.
102
+ --https-pfx <value> Path to an SSL pfx file.
103
+ --https-cert <value> Path to an SSL certificate.
104
+ --https-cacert <value> Path to an SSL CA certificate.
105
+ --https-request-cert Request for an SSL certificate.
106
+ --no-https-request-cert Do not request for an SSL certificate.
107
+ --http2 Use HTTP/2, must be used with HTTPS.
108
+ --no-http2 Do not use HTTP/2.
109
+ --bonjour Broadcasts the server via ZeroConf networking on start.
110
+ --no-bonjour Do not broadcast the server via ZeroConf networking on start.
111
+ --client-progress Print compilation progress in percentage in the browser.
112
+ --no-client-progress Do not print compilation progress in percentage in the browser.
113
+ --client-overlay Show a full-screen overlay in the browser when there are compiler errors or warnings.
114
+ --no-client-overlay Do not show a full-screen overlay in the browser when there are compiler errors or warnings.
115
+ --open [value...] Open the default browser.
116
+ --no-open Do not open the default browser.
117
+ --open-app <value> Open specified browser.
118
+ --open-target [value...] Open specified route in browser.
119
+ --no-open-target Do not open specified route in browser.
120
+ --client-logging <value> Log level in the browser (none, error, warn, info, log, verbose).
121
+ --history-api-fallback Fallback to /index.html for Single Page Applications.
122
+ --no-history-api-fallback Do not fallback to /index.html for Single Page Applications.
123
+ --compress Enable gzip compression.
124
+ --no-compress Disable gzip compression.
125
+ --public <value> The public hostname/ip address of the server.
126
+ --firewall [value...] Enable firewall or set hosts that are allowed to access the dev server.
127
+ --no-firewall Disable firewall.
128
+ --watch-files <value...> Watch static files for file changes.
118
129
 
119
130
  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.
131
+ --color Enable colors on console.
132
+ --no-color Disable colors on console.
133
+ -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
134
+ -h, --help [verbose] Display help for commands and options.
124
135
  ```
125
136
 
126
137
  _**Note**: For more information on above options explore this [link](https://webpack.js.org/configuration/dev-server/)._
@@ -142,7 +153,7 @@ script as such:
142
153
  And run the following in your terminal/console:
143
154
 
144
155
  ```console
145
- npm run start:dev
156
+ npm run serve
146
157
  ```
147
158
 
148
159
  NPM will automagically reference the binary in `node_modules` for you, and
package/bin/cli-flags.js CHANGED
@@ -37,6 +37,73 @@ module.exports = {
37
37
  multiple: true,
38
38
  negative: true,
39
39
  },
40
+ {
41
+ name: 'static-directory',
42
+ type: String,
43
+ configs: [
44
+ {
45
+ type: 'string',
46
+ },
47
+ ],
48
+ description: 'Directory for static contents.',
49
+ processor(opts) {
50
+ opts.static = opts.static || {};
51
+ opts.static.directory = opts.staticDirectory;
52
+ delete opts.staticDirectory;
53
+ },
54
+ },
55
+ {
56
+ name: 'static-public-path',
57
+ type: String,
58
+ configs: [
59
+ {
60
+ type: 'string',
61
+ },
62
+ ],
63
+ description:
64
+ 'The bundled files will be available in the browser under this path.',
65
+ multiple: true,
66
+ processor(opts) {
67
+ opts.static = opts.static || {};
68
+ opts.static.publicPath = opts.staticPublicPath;
69
+ delete opts.staticPublicPath;
70
+ },
71
+ },
72
+ {
73
+ name: 'static-serve-index',
74
+ type: Boolean,
75
+ configs: [
76
+ {
77
+ type: 'boolean',
78
+ },
79
+ ],
80
+ description: 'Tells dev-server to use serveIndex middleware.',
81
+ negatedDescription:
82
+ 'Do not tell dev-server to use serveIndex middleware.',
83
+ negative: true,
84
+ processor(opts) {
85
+ opts.static = opts.static || {};
86
+ opts.static.serveIndex = opts.staticServeIndex;
87
+ delete opts.staticServeIndex;
88
+ },
89
+ },
90
+ {
91
+ name: 'static-watch',
92
+ type: Boolean,
93
+ configs: [
94
+ {
95
+ type: 'boolean',
96
+ },
97
+ ],
98
+ description: 'Watch for files in static content directory.',
99
+ negatedDescription: 'Do not watch for files in static content directory.',
100
+ negative: true,
101
+ processor(opts) {
102
+ opts.static = opts.static || {};
103
+ opts.static.watch = opts.staticWatch;
104
+ delete opts.staticWatch;
105
+ },
106
+ },
40
107
  {
41
108
  name: 'live-reload',
42
109
  type: Boolean,
@@ -61,6 +128,97 @@ module.exports = {
61
128
  negatedDescription: 'Do not use HTTPS protocol.',
62
129
  negative: true,
63
130
  },
131
+ {
132
+ name: 'https-passphrase',
133
+ type: String,
134
+ configs: [
135
+ {
136
+ type: 'string',
137
+ },
138
+ ],
139
+ description: 'Passphrase for a pfx file.',
140
+ processor(opts) {
141
+ opts.https = opts.https || {};
142
+ opts.https.passphrase = opts.httpsPassphrase;
143
+ delete opts.httpsPassphrase;
144
+ },
145
+ },
146
+ {
147
+ name: 'https-key',
148
+ type: String,
149
+ configs: [
150
+ {
151
+ type: 'string',
152
+ },
153
+ ],
154
+ description: 'Path to an SSL key.',
155
+ processor(opts) {
156
+ opts.https = opts.https || {};
157
+ opts.https.key = opts.httpsKey;
158
+ delete opts.httpsKey;
159
+ },
160
+ },
161
+ {
162
+ name: 'https-pfx',
163
+ type: String,
164
+ configs: [
165
+ {
166
+ type: 'string',
167
+ },
168
+ ],
169
+ description: 'Path to an SSL pfx file.',
170
+ processor(opts) {
171
+ opts.https = opts.https || {};
172
+ opts.https.pfx = opts.httpsPfx;
173
+ delete opts.httpsPfx;
174
+ },
175
+ },
176
+ {
177
+ name: 'https-cert',
178
+ type: String,
179
+ configs: [
180
+ {
181
+ type: 'string',
182
+ },
183
+ ],
184
+ description: 'Path to an SSL certificate.',
185
+ processor(opts) {
186
+ opts.https = opts.https || {};
187
+ opts.https.cert = opts.httpsCert;
188
+ delete opts.httpsCert;
189
+ },
190
+ },
191
+ {
192
+ name: 'https-cacert',
193
+ type: String,
194
+ configs: [
195
+ {
196
+ type: 'string',
197
+ },
198
+ ],
199
+ description: 'Path to an SSL CA certificate.',
200
+ processor(opts) {
201
+ opts.https = opts.https || {};
202
+ opts.https.cacert = opts.httpsCacert;
203
+ delete opts.httpsCacert;
204
+ },
205
+ },
206
+ {
207
+ name: 'https-request-cert',
208
+ type: Boolean,
209
+ configs: [
210
+ {
211
+ type: 'boolean',
212
+ },
213
+ ],
214
+ description: 'Request for an SSL certificate.',
215
+ negatedDescription: 'Do not request for an SSL certificate.',
216
+ processor(opts) {
217
+ opts.https = opts.https || {};
218
+ opts.https.requestCert = opts.httpsRequestCert;
219
+ delete opts.httpsRequestCert;
220
+ },
221
+ },
64
222
  {
65
223
  name: 'http2',
66
224
  type: Boolean,
@@ -123,19 +281,6 @@ module.exports = {
123
281
  delete opts.clientOverlay;
124
282
  },
125
283
  },
126
- {
127
- name: 'setup-exit-signals',
128
- type: Boolean,
129
- configs: [
130
- {
131
- type: 'boolean',
132
- },
133
- ],
134
- description: 'Close and exit the process on SIGINT and SIGTERM.',
135
- negatedDescription:
136
- 'Do not close and exit the process on SIGNIT and SIGTERM.',
137
- negative: true,
138
- },
139
284
  // TODO remove in the next major release in favor `--open-target`
140
285
  {
141
286
  name: 'open',
@@ -37,12 +37,12 @@ module.exports = /*#__PURE__*/function (_BaseClient) {
37
37
 
38
38
  _classCallCheck(this, SockJSClient);
39
39
 
40
- _this = _super.call(this);
41
- var sockUrl = url.replace(/^(?:chrome-extension|file)/i, 'http');
42
- _this.sock = new SockJS(sockUrl);
40
+ _this = _super.call(this); // SockJS requires `http` and `https` protocols
43
41
 
44
- _this.sock.onerror = function (err) {
45
- log.error(err);
42
+ _this.sock = new SockJS(url.replace(/^ws:/i, 'http:').replace(/^wss:/i, 'https:'));
43
+
44
+ _this.sock.onerror = function (error) {
45
+ log.error(error);
46
46
  };
47
47
 
48
48
  return _this;
@@ -36,11 +36,10 @@ module.exports = /*#__PURE__*/function (_BaseClient) {
36
36
  _classCallCheck(this, WebsocketClient);
37
37
 
38
38
  _this = _super.call(this);
39
- var wsUrl = url.replace(/^(?:http|chrome-extension|file)/i, 'ws');
40
- _this.client = new WebSocket(wsUrl);
39
+ _this.client = new WebSocket(url);
41
40
 
42
- _this.client.onerror = function (err) {
43
- log.error(err);
41
+ _this.client.onerror = function (error) {
42
+ log.error(error);
44
43
  };
45
44
 
46
45
  return _this;
package/client/index.js CHANGED
@@ -1,8 +1,28 @@
1
1
  'use strict';
2
2
  /* global __resourceQuery WorkerGlobalScope */
3
3
 
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+
8
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
9
+
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+
12
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
+
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+
18
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ var webpackHotLog = require('webpack/hot/log');
21
+
4
22
  var stripAnsi = require('./modules/strip-ansi');
5
23
 
24
+ var parseURL = require('./utils/parseURL');
25
+
6
26
  var socket = require('./socket');
7
27
 
8
28
  var overlay = require('./overlay');
@@ -15,22 +35,64 @@ var sendMessage = require('./utils/sendMessage');
15
35
 
16
36
  var reloadApp = require('./utils/reloadApp');
17
37
 
18
- var createSocketUrl = require('./utils/createSocketUrl');
38
+ var createSocketURL = require('./utils/createSocketURL');
19
39
 
20
40
  var status = {
21
41
  isUnloading: false,
22
42
  currentHash: ''
23
43
  };
24
- var options = {
44
+ var defaultOptions = {
25
45
  hot: false,
26
46
  hotReload: true,
27
47
  liveReload: false,
28
48
  initial: true,
29
- useWarningOverlay: false,
30
- useErrorOverlay: false,
31
- useProgress: false
49
+ progress: false,
50
+ overlay: false
32
51
  };
33
- var socketUrl = createSocketUrl(__resourceQuery);
52
+ var parsedResourceQuery = parseURL(__resourceQuery);
53
+ var options = defaultOptions; // Handle Node.js legacy format and `new URL()`
54
+
55
+ if (parsedResourceQuery.query) {
56
+ _extends(options, parsedResourceQuery.query);
57
+ } else if (parsedResourceQuery.searchParams) {
58
+ var paramsToObject = function paramsToObject(entries) {
59
+ var result = {};
60
+
61
+ var _iterator = _createForOfIteratorHelper(entries),
62
+ _step;
63
+
64
+ try {
65
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
66
+ var _step$value = _slicedToArray(_step.value, 2),
67
+ key = _step$value[0],
68
+ value = _step$value[1];
69
+
70
+ result[key] = value;
71
+ }
72
+ } catch (err) {
73
+ _iterator.e(err);
74
+ } finally {
75
+ _iterator.f();
76
+ }
77
+
78
+ return result;
79
+ };
80
+
81
+ _extends(options, paramsToObject(parsedResourceQuery.searchParams.entries()));
82
+ }
83
+
84
+ var socketURL = createSocketURL(parsedResourceQuery);
85
+
86
+ function setAllLogLevel(level) {
87
+ // This is needed because the HMR logger operate separately from dev server logger
88
+ webpackHotLog.setLogLevel(level);
89
+ setLogLevel(level);
90
+ }
91
+
92
+ if (options.logging) {
93
+ setAllLogLevel(options.logging);
94
+ }
95
+
34
96
  self.addEventListener('beforeunload', function () {
35
97
  status.isUnloading = true;
36
98
  });
@@ -50,9 +112,9 @@ var onSocketMessage = {
50
112
  log.info('Live Reloading enabled.');
51
113
  },
52
114
  invalid: function invalid() {
53
- log.info('App updated. Recompiling...'); // fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
115
+ log.info('App updated. Recompiling...'); // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
54
116
 
55
- if (options.useWarningOverlay || options.useErrorOverlay) {
117
+ if (options.overlay) {
56
118
  overlay.clear();
57
119
  }
58
120
 
@@ -61,53 +123,37 @@ var onSocketMessage = {
61
123
  hash: function hash(_hash) {
62
124
  status.currentHash = _hash;
63
125
  },
64
- 'still-ok': function stillOk() {
65
- log.info('Nothing changed.');
66
-
67
- if (options.useWarningOverlay || options.useErrorOverlay) {
68
- overlay.clear();
69
- }
70
-
71
- sendMessage('StillOk');
72
- },
73
- logging: function logging(level) {
74
- // this is needed because the HMR logger operate separately from
75
- // dev server logger
76
- var hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
77
-
78
- if (hotCtx.keys().indexOf('./log') !== -1) {
79
- hotCtx('./log').setLogLevel(level);
80
- }
81
-
82
- setLogLevel(level);
83
- },
126
+ logging: setAllLogLevel,
84
127
  overlay: function overlay(value) {
85
- if (typeof document !== 'undefined') {
86
- if (typeof value === 'boolean') {
87
- options.useWarningOverlay = false;
88
- options.useErrorOverlay = value;
89
- } else if (value) {
90
- options.useWarningOverlay = value.warnings;
91
- options.useErrorOverlay = value.errors;
92
- }
128
+ if (typeof document === 'undefined') {
129
+ return;
93
130
  }
131
+
132
+ options.overlay = value;
94
133
  },
95
134
  progress: function progress(_progress) {
96
- if (typeof document !== 'undefined') {
97
- options.useProgress = _progress;
98
- }
135
+ options.progress = _progress;
99
136
  },
100
137
  'progress-update': function progressUpdate(data) {
101
- if (options.useProgress) {
138
+ if (options.progress) {
102
139
  log.info("".concat(data.percent, "% - ").concat(data.msg, "."));
103
140
  }
104
141
 
105
142
  sendMessage('Progress', data);
106
143
  },
144
+ 'still-ok': function stillOk() {
145
+ log.info('Nothing changed.');
146
+
147
+ if (options.overlay) {
148
+ overlay.clear();
149
+ }
150
+
151
+ sendMessage('StillOk');
152
+ },
107
153
  ok: function ok() {
108
154
  sendMessage('Ok');
109
155
 
110
- if (options.useWarningOverlay || options.useErrorOverlay) {
156
+ if (options.overlay) {
111
157
  overlay.clear();
112
158
  }
113
159
 
@@ -134,7 +180,9 @@ var onSocketMessage = {
134
180
  log.warn(strippedWarnings[i]);
135
181
  }
136
182
 
137
- if (options.useWarningOverlay) {
183
+ var needShowOverlay = typeof options.overlay === 'boolean' ? options.overlay : options.overlay && options.overlay.warnings;
184
+
185
+ if (needShowOverlay) {
138
186
  overlay.showMessage(_warnings);
139
187
  }
140
188
 
@@ -157,7 +205,9 @@ var onSocketMessage = {
157
205
  log.error(strippedErrors[i]);
158
206
  }
159
207
 
160
- if (options.useErrorOverlay) {
208
+ var needShowOverlay = typeof options.overlay === 'boolean' ? options.overlay : options.overlay && options.overlay.errors;
209
+
210
+ if (needShowOverlay) {
161
211
  overlay.showMessage(_errors);
162
212
  }
163
213
 
@@ -171,4 +221,4 @@ var onSocketMessage = {
171
221
  sendMessage('Close');
172
222
  }
173
223
  };
174
- socket(socketUrl, onSocketMessage);
224
+ socket(socketURL, onSocketMessage);