webpack-dev-server 2.2.0 → 2.4.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/README.md +1 -1
- package/bin/webpack-dev-server.js +10 -32
- package/client/index.bundle.js +3 -3
- package/client/index.js +19 -0
- package/client/live.bundle.js +6 -6
- package/client/overlay.js +126 -0
- package/client/sockjs.bundle.js +2 -2
- package/client/webpack.config.js +16 -8
- package/lib/OptionsValidationError.js +107 -101
- package/lib/Server.js +12 -2
- package/lib/optionsSchema.json +27 -1
- package/lib/util/addDevServerEntrypoints.js +24 -0
- package/lib/util/createDomain.js +13 -0
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ This will start a server, listening on connections from `localhost` on port `808
|
|
|
39
39
|
|
|
40
40
|
Now, when you change something in your assets, it should live-reload the files.
|
|
41
41
|
|
|
42
|
-
See [**the documentation**](
|
|
42
|
+
See [**the documentation**](https://webpack.js.org/configuration/dev-server/#devserver) for more use cases and options.
|
|
43
43
|
|
|
44
44
|
<h2 align="center">Contributing</h2>
|
|
45
45
|
|
|
@@ -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 {
|
|
@@ -40,7 +41,7 @@ function colorError(useColor, msg) {
|
|
|
40
41
|
|
|
41
42
|
const yargs = require("yargs")
|
|
42
43
|
.usage(`${versionInfo()
|
|
43
|
-
}\nUsage:
|
|
44
|
+
}\nUsage: https://webpack.js.org/configuration/dev-server/`);
|
|
44
45
|
|
|
45
46
|
require("webpack/bin/config-yargs")(yargs);
|
|
46
47
|
|
|
@@ -327,33 +328,7 @@ function processOptions(wpOpt) {
|
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
function startDevServer(wpOpt, options) {
|
|
330
|
-
|
|
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
|
-
}
|
|
331
|
+
addDevServerEntrypoints(wpOpt, options);
|
|
357
332
|
|
|
358
333
|
let compiler;
|
|
359
334
|
try {
|
|
@@ -372,7 +347,7 @@ function startDevServer(wpOpt, options) {
|
|
|
372
347
|
}));
|
|
373
348
|
}
|
|
374
349
|
|
|
375
|
-
const uri =
|
|
350
|
+
const uri = createDomain(options) + (options.inline !== false || options.lazy === true ? "/" : "/webpack-dev-server/");
|
|
376
351
|
|
|
377
352
|
let server;
|
|
378
353
|
try {
|
|
@@ -434,8 +409,11 @@ function reportReadiness(uri, options) {
|
|
|
434
409
|
console.log(`Content not from webpack is served from ${colorInfo(useColor, contentBase)}`);
|
|
435
410
|
if(options.historyApiFallback)
|
|
436
411
|
console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || "/index.html")}`);
|
|
437
|
-
if(options.open)
|
|
438
|
-
open(uri)
|
|
412
|
+
if(options.open) {
|
|
413
|
+
open(uri).catch(function() {
|
|
414
|
+
console.log("Unable to open browser. If you are running in a headless environment, please do not use the open flag.");
|
|
415
|
+
});
|
|
416
|
+
}
|
|
439
417
|
}
|
|
440
418
|
|
|
441
419
|
processOptions(wpOpt);
|