webpack-dev-server 2.4.5 → 2.6.1

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/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright JS Foundation and other contributors
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,86 +1,86 @@
1
- # webpack-dev-server
2
-
3
- [![npm][npm]][npm-url]
4
- [![node][node]][node-url]
5
- [![deps][deps]][deps-url]
6
- [![tests][tests]][tests-url]
7
- [![coverage][cover]][cover-url]
8
- [![chat][chat]][chat-url]
9
-
10
- <div align="center">
11
- <a href="https://github.com/webpack/webpack">
12
- <img width="200" height="200"
13
- src="https://webpack.js.org/assets/icon-square-big.svg">
14
- </a>
15
- <h1>webpack Dev Server</h1>
16
- </div>
17
-
18
- Use [webpack](https://webpack.js.org) with a development server that provides live reloading. This should be used for **development only**.
19
-
20
- It uses [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) under the hood, which provides fast in-memory access to the webpack assets.
21
-
22
- <h2 align="center">Install</h2>
23
-
24
- ```
25
- npm install webpack-dev-server --save-dev
26
- ```
27
-
28
- <h2 align="center">Usage</h2>
29
-
30
- The easiest way to use it is with the CLI. In the directory where your `webpack.config.js` is, run:
31
-
32
- ```
33
- node_modules/.bin/webpack-dev-server
34
- ```
35
-
36
- This will start a server, listening on connections from `localhost` on port `8080`.
37
-
38
- Now, when you change something in your assets, it should live-reload the files.
39
-
40
- See [**the documentation**](https://webpack.js.org/configuration/dev-server/#devserver) for more use cases and options.
41
-
42
- <h2 align="center">Contributing</h2>
43
-
44
- We appreciate all help! Check out [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to help.
45
-
46
- <h2 align="center">Maintainers</h2>
47
-
48
- <table>
49
- <tbody>
50
- <tr>
51
- <td align="center">
52
- <img width="150" height="150"
53
- src="https://avatars.githubusercontent.com/SpaceK33z?v=3">
54
- <br />
55
- <a href="https://github.com/">Kees Kluskens</a>
56
- </td>
57
- </tr>
58
- </tbody>
59
- </table>
60
-
61
- <h2 align="center">Inspiration</h2>
62
-
63
- This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
64
-
65
- <h2 align="center">LICENSE</h2>
66
-
67
- #### [MIT](./LICENSE)
68
-
69
-
70
- [npm]: https://img.shields.io/npm/v/webpack-dev-server.svg
71
- [npm-url]: https://npmjs.com/package/webpack-dev-server
72
-
73
- [node]: https://img.shields.io/node/v/webpack-dev-server.svg
74
- [node-url]: https://nodejs.org
75
-
76
- [deps]: https://david-dm.org/webpack/webpack-dev-server.svg
77
- [deps-url]: https://david-dm.org/webpack/webpack-dev-server
78
-
79
- [tests]: http://img.shields.io/travis/webpack/webpack-dev-server.svg
80
- [tests-url]: https://travis-ci.org/webpack/webpack-dev-server
81
-
82
- [cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
83
- [cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
84
-
85
- [chat]: https://badges.gitter.im/webpack/webpack.svg
86
- [chat-url]: https://gitter.im/webpack/webpack
1
+ # webpack-dev-server
2
+
3
+ [![npm][npm]][npm-url]
4
+ [![node][node]][node-url]
5
+ [![deps][deps]][deps-url]
6
+ [![tests][tests]][tests-url]
7
+ [![coverage][cover]][cover-url]
8
+ [![chat][chat]][chat-url]
9
+
10
+ <div align="center">
11
+ <a href="https://github.com/webpack/webpack">
12
+ <img width="200" height="200"
13
+ src="https://webpack.js.org/assets/icon-square-big.svg">
14
+ </a>
15
+ <h1>webpack Dev Server</h1>
16
+ </div>
17
+
18
+ Use [webpack](https://webpack.js.org) with a development server that provides live reloading. This should be used for **development only**.
19
+
20
+ It uses [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) under the hood, which provides fast in-memory access to the webpack assets.
21
+
22
+ <h2 align="center">Install</h2>
23
+
24
+ ```
25
+ npm install webpack-dev-server --save-dev
26
+ ```
27
+
28
+ <h2 align="center">Usage</h2>
29
+
30
+ The easiest way to use it is with the CLI. In the directory where your `webpack.config.js` is, run:
31
+
32
+ ```
33
+ node_modules/.bin/webpack-dev-server
34
+ ```
35
+
36
+ This will start a server, listening on connections from `localhost` on port `8080`.
37
+
38
+ Now, when you change something in your assets, it should live-reload the files.
39
+
40
+ See [**the documentation**](https://webpack.js.org/configuration/dev-server/#devserver) for more use cases and options.
41
+
42
+ <h2 align="center">Contributing</h2>
43
+
44
+ We appreciate all help! Check out [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to help.
45
+
46
+ <h2 align="center">Maintainers</h2>
47
+
48
+ <table>
49
+ <tbody>
50
+ <tr>
51
+ <td align="center">
52
+ <img width="150" height="150"
53
+ src="https://avatars.githubusercontent.com/SpaceK33z?v=3">
54
+ <br />
55
+ <a href="https://github.com/SpaceK33z">Kees Kluskens</a>
56
+ </td>
57
+ </tr>
58
+ </tbody>
59
+ </table>
60
+
61
+ <h2 align="center">Inspiration</h2>
62
+
63
+ This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/nof5).
64
+
65
+ <h2 align="center">LICENSE</h2>
66
+
67
+ #### [MIT](./LICENSE)
68
+
69
+
70
+ [npm]: https://img.shields.io/npm/v/webpack-dev-server.svg
71
+ [npm-url]: https://npmjs.com/package/webpack-dev-server
72
+
73
+ [node]: https://img.shields.io/node/v/webpack-dev-server.svg
74
+ [node-url]: https://nodejs.org
75
+
76
+ [deps]: https://david-dm.org/webpack/webpack-dev-server.svg
77
+ [deps-url]: https://david-dm.org/webpack/webpack-dev-server
78
+
79
+ [tests]: http://img.shields.io/travis/webpack/webpack-dev-server.svg
80
+ [tests-url]: https://travis-ci.org/webpack/webpack-dev-server
81
+
82
+ [cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
83
+ [cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
84
+
85
+ [chat]: https://badges.gitter.im/webpack/webpack.svg
86
+ [chat-url]: https://gitter.im/webpack/webpack
@@ -39,6 +39,8 @@ function colorError(useColor, msg) {
39
39
  return msg;
40
40
  }
41
41
 
42
+ const defaultTo = (value, def) => value == null ? def : value;
43
+
42
44
  const yargs = require("yargs")
43
45
  .usage(`${versionInfo()
44
46
  }\nUsage: https://webpack.js.org/configuration/dev-server/`);
@@ -62,6 +64,10 @@ const BASIC_GROUP = "Basic options:";
62
64
  const DEFAULT_PORT = 8080;
63
65
 
64
66
  yargs.options({
67
+ "bonjour": {
68
+ type: "boolean",
69
+ describe: "Broadcasts the server via ZeroConf networking on start"
70
+ },
65
71
  "lazy": {
66
72
  type: "boolean",
67
73
  describe: "Lazy"
@@ -89,6 +95,15 @@ yargs.options({
89
95
  type: "boolean",
90
96
  describe: "Open default browser"
91
97
  },
98
+ "useLocalIp": {
99
+ type: "boolean",
100
+ describe: "Open default browser with local IP"
101
+ },
102
+ "open-page": {
103
+ type: "string",
104
+ describe: "Open default browser with the specified page",
105
+ requiresArg: true,
106
+ },
92
107
  "color": {
93
108
  type: "boolean",
94
109
  alias: "colors",
@@ -169,6 +184,11 @@ yargs.options({
169
184
  describe: "The port",
170
185
  group: CONNECTION_GROUP
171
186
  },
187
+ "disable-host-check": {
188
+ type: "boolean",
189
+ describe: "Will not check the host",
190
+ group: CONNECTION_GROUP
191
+ },
172
192
  "socket": {
173
193
  type: "String",
174
194
  describe: "Socket to listen",
@@ -207,6 +227,9 @@ function processOptions(wpOpt) {
207
227
 
208
228
  const options = wpOpt.devServer || firstWpOpt.devServer || {};
209
229
 
230
+ if(argv.bonjour)
231
+ options.bonjour = true;
232
+
210
233
  if(argv.host !== "localhost" || !options.host)
211
234
  options.host = argv.host;
212
235
 
@@ -310,15 +333,23 @@ function processOptions(wpOpt) {
310
333
  if(argv["compress"])
311
334
  options.compress = true;
312
335
 
313
- if(argv["open"])
336
+ if(argv["disable-host-check"])
337
+ options.disableHostCheck = true;
338
+
339
+ if(argv["open"] || argv["open-page"]) {
314
340
  options.open = true;
341
+ options.openPage = argv["open-page"] || "";
342
+ }
343
+
344
+ if(argv["useLocalIp"])
345
+ options.useLocalIp = true;
315
346
 
316
347
  // Kind of weird, but ensures prior behavior isn't broken in cases
317
348
  // that wouldn't throw errors. E.g. both argv.port and options.port
318
349
  // were specified, but since argv.port is 8080, options.port will be
319
350
  // tried first instead.
320
- options.port = argv.port === DEFAULT_PORT ? (options.port || argv.port) : (argv.port || options.port);
321
- if(options.port) {
351
+ options.port = argv.port === DEFAULT_PORT ? defaultTo(options.port, argv.port) : defaultTo(argv.port, options.port);
352
+ if(options.port != null) {
322
353
  startDevServer(wpOpt, options);
323
354
  return;
324
355
  }
@@ -401,6 +432,7 @@ function startDevServer(wpOpt, options) {
401
432
  } else {
402
433
  server.listen(options.port, options.host, function(err) {
403
434
  if(err) throw err;
435
+ if(options.bonjour) broadcastZeroconf(options);
404
436
  reportReadiness(uri, options);
405
437
  });
406
438
  }
@@ -408,23 +440,42 @@ function startDevServer(wpOpt, options) {
408
440
 
409
441
  function reportReadiness(uri, options) {
410
442
  const useColor = argv.color;
411
- let startSentence = `Project is running at ${colorInfo(useColor, uri)}`
412
- if(options.socket) {
413
- startSentence = `Listening to socket at ${colorInfo(useColor, options.socket)}`;
414
- }
415
- console.log((argv["progress"] ? "\n" : "") + startSentence);
443
+ if(!options.quiet) {
444
+ let startSentence = `Project is running at ${colorInfo(useColor, uri)}`
445
+ if(options.socket) {
446
+ startSentence = `Listening to socket at ${colorInfo(useColor, options.socket)}`;
447
+ }
448
+ console.log((argv["progress"] ? "\n" : "") + startSentence);
416
449
 
417
- console.log(`webpack output is served from ${colorInfo(useColor, options.publicPath)}`);
450
+ console.log(`webpack output is served from ${colorInfo(useColor, options.publicPath)}`);
451
+ }
418
452
  const contentBase = Array.isArray(options.contentBase) ? options.contentBase.join(", ") : options.contentBase;
419
453
  if(contentBase)
420
454
  console.log(`Content not from webpack is served from ${colorInfo(useColor, contentBase)}`);
421
455
  if(options.historyApiFallback)
422
456
  console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || "/index.html")}`);
423
457
  if(options.open) {
424
- open(uri).catch(function() {
458
+ open(uri + options.openPage).catch(function() {
425
459
  console.log("Unable to open browser. If you are running in a headless environment, please do not use the open flag.");
426
460
  });
427
461
  }
462
+ if(options.bonjour)
463
+ console.log("Broadcasting \"http\" with subtype of \"webpack\" via ZeroConf DNS (Bonjour)");
464
+ }
465
+
466
+ function broadcastZeroconf(options) {
467
+ const bonjour = require("bonjour")();
468
+ bonjour.publish({
469
+ name: "Webpack Dev Server",
470
+ port: options.port,
471
+ type: "http",
472
+ subtypes: ["webpack"]
473
+ });
474
+ process.on("exit", function() {
475
+ bonjour.unpublishAll(function() {
476
+ bonjour.destroy();
477
+ });
478
+ });
428
479
  }
429
480
 
430
481
  processOptions(wpOpt);