webpack-dev-server 2.2.1 → 2.4.2

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
@@ -19,8 +19,6 @@ Use [webpack](https://webpack.js.org) with a development server that provides li
19
19
 
20
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
21
 
22
- **Note: There are known issues with Node.js v7 and webpack / webpack-dev-server. Please use Node.js v6 for the moment.**
23
-
24
22
  <h2 align="center">Install</h2>
25
23
 
26
24
  ```
@@ -5,8 +5,9 @@ const path = require("path");
5
5
  const open = require("opn");
6
6
  const fs = require("fs");
7
7
  const net = require("net");
8
- const url = require("url");
9
8
  const portfinder = require("portfinder");
9
+ const addDevServerEntrypoints = require("../lib/util/addDevServerEntrypoints");
10
+ const createDomain = require("../lib/util/createDomain");
10
11
 
11
12
  // Local version replaces global one
12
13
  try {
@@ -246,7 +247,11 @@ function processOptions(wpOpt) {
246
247
  if(options.contentBase === undefined) {
247
248
  if(argv["content-base"]) {
248
249
  options.contentBase = argv["content-base"];
249
- if(/^[0-9]$/.test(options.contentBase))
250
+ if(Array.isArray(options.contentBase)) {
251
+ options.contentBase = options.contentBase.map(function(val) {
252
+ return path.resolve(val);
253
+ });
254
+ } else if(/^[0-9]$/.test(options.contentBase))
250
255
  options.contentBase = +options.contentBase;
251
256
  else if(!/^(https?:)?\/\//.test(options.contentBase))
252
257
  options.contentBase = path.resolve(options.contentBase);
@@ -327,33 +332,7 @@ function processOptions(wpOpt) {
327
332
  }
328
333
 
329
334
  function startDevServer(wpOpt, options) {
330
- const protocol = options.https ? "https" : "http";
331
-
332
- // the formatted domain (url without path) of the webpack server
333
- const domain = url.format({
334
- protocol: protocol,
335
- hostname: options.host,
336
- port: options.socket ? 0 : options.port.toString()
337
- });
338
-
339
- if(options.inline !== false) {
340
- const devClient = [`${require.resolve("../client/")}?${options.public ? `${protocol}://${options.public}` : domain}`];
341
-
342
- if(options.hotOnly)
343
- devClient.push("webpack/hot/only-dev-server");
344
- else if(options.hot)
345
- devClient.push("webpack/hot/dev-server");
346
-
347
- [].concat(wpOpt).forEach(function(wpOpt) {
348
- if(typeof wpOpt.entry === "object" && !Array.isArray(wpOpt.entry)) {
349
- Object.keys(wpOpt.entry).forEach(function(key) {
350
- wpOpt.entry[key] = devClient.concat(wpOpt.entry[key]);
351
- });
352
- } else {
353
- wpOpt.entry = devClient.concat(wpOpt.entry);
354
- }
355
- });
356
- }
335
+ addDevServerEntrypoints(wpOpt, options);
357
336
 
358
337
  let compiler;
359
338
  try {
@@ -372,7 +351,7 @@ function startDevServer(wpOpt, options) {
372
351
  }));
373
352
  }
374
353
 
375
- const uri = domain + (options.inline !== false || options.lazy === true ? "/" : "/webpack-dev-server/");
354
+ const uri = createDomain(options) + (options.inline !== false || options.lazy === true ? "/" : "/webpack-dev-server/");
376
355
 
377
356
  let server;
378
357
  try {
@@ -386,6 +365,13 @@ function startDevServer(wpOpt, options) {
386
365
  throw e;
387
366
  }
388
367
 
368
+ ["SIGINT", "SIGTERM"].forEach(function(sig) {
369
+ process.on(sig, function() {
370
+ server.close();
371
+ process.exit(); // eslint-disable-line no-process-exit
372
+ });
373
+ });
374
+
389
375
  if(options.socket) {
390
376
  server.listeningApp.on("error", function(e) {
391
377
  if(e.code === "EADDRINUSE") {
@@ -434,8 +420,11 @@ function reportReadiness(uri, options) {
434
420
  console.log(`Content not from webpack is served from ${colorInfo(useColor, contentBase)}`);
435
421
  if(options.historyApiFallback)
436
422
  console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || "/index.html")}`);
437
- if(options.open)
438
- open(uri);
423
+ if(options.open) {
424
+ open(uri).catch(function() {
425
+ console.log("Unable to open browser. If you are running in a headless environment, please do not use the open flag.");
426
+ });
427
+ }
439
428
  }
440
429
 
441
430
  processOptions(wpOpt);