webpack-dev-server 2.8.1 → 2.9.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/client/live.js CHANGED
@@ -10,7 +10,7 @@ require('./style.css');
10
10
  let hot = false;
11
11
  let currentHash = '';
12
12
 
13
- $(() => {
13
+ $(function ready() {
14
14
  $('body').html(require('./page.pug')());
15
15
  const status = $('#status');
16
16
  const okness = $('#okness');
@@ -28,11 +28,11 @@ $(() => {
28
28
  });
29
29
 
30
30
  const onSocketMsg = {
31
- hot() {
31
+ hot: function msgHot() {
32
32
  hot = true;
33
33
  iframe.attr('src', contentPage + window.location.hash);
34
34
  },
35
- invalid() {
35
+ invalid: function msgInvalid() {
36
36
  okness.text('');
37
37
  status.text('App updated. Recompiling...');
38
38
  header.css({
@@ -41,7 +41,7 @@ $(() => {
41
41
  $errors.hide();
42
42
  if (!hot) iframe.hide();
43
43
  },
44
- hash(hash) {
44
+ hash: function msgHash(hash) {
45
45
  currentHash = hash;
46
46
  },
47
47
  'still-ok': function stillOk() {
@@ -53,27 +53,27 @@ $(() => {
53
53
  $errors.hide();
54
54
  if (!hot) iframe.show();
55
55
  },
56
- ok() {
56
+ ok: function msgOk() {
57
57
  okness.text('');
58
58
  $errors.hide();
59
59
  reloadApp();
60
60
  },
61
- warnings() {
61
+ warnings: function msgWarnings() {
62
62
  okness.text('Warnings while compiling.');
63
63
  $errors.hide();
64
64
  reloadApp();
65
65
  },
66
- errors(errors) {
66
+ errors: function msgErrors(errors) {
67
67
  status.text('App updated with errors. No reload!');
68
68
  okness.text('Errors while compiling.');
69
- $errors.text(`\n${stripAnsi(errors.join('\n\n\n'))}\n\n`);
69
+ $errors.text('\n' + stripAnsi(errors.join('\n\n\n')) + '\n\n');
70
70
  header.css({
71
71
  borderColor: '#ebcb8b'
72
72
  });
73
73
  $errors.show();
74
74
  iframe.hide();
75
75
  },
76
- close() {
76
+ close: function msgClose() {
77
77
  status.text('');
78
78
  okness.text('Disconnected.');
79
79
  $errors.text('\n\n\n Lost connection to webpack-dev-server.\n Please restart the server to reestablish connection...\n\n\n\n');
@@ -87,7 +87,7 @@ $(() => {
87
87
 
88
88
  socket('/sockjs-node', onSocketMsg);
89
89
 
90
- iframe.on('load', () => {
90
+ iframe.on('load', function load() {
91
91
  status.text('App ready.');
92
92
  header.css({
93
93
  borderColor: ''
@@ -99,7 +99,7 @@ $(() => {
99
99
  if (hot) {
100
100
  status.text('App hot update.');
101
101
  try {
102
- iframe[0].contentWindow.postMessage(`webpackHotUpdate${currentHash}`, '*');
102
+ iframe[0].contentWindow.postMessage('webpackHotUpdate' + currentHash, '*');
103
103
  } catch (e) {
104
104
  console.warn(e); // eslint-disable-line
105
105
  }
@@ -110,7 +110,7 @@ $(() => {
110
110
  borderColor: '#96b5b4'
111
111
  });
112
112
  try {
113
- let old = `${iframe[0].contentWindow.location}`;
113
+ let old = iframe[0].contentWindow.location + '';
114
114
  if (old.indexOf('about') === 0) old = null;
115
115
  iframe.attr('src', old || (contentPage + window.location.hash));
116
116
  if (old) {
package/client/overlay.js CHANGED
@@ -50,7 +50,7 @@ function addOverlayDivTo(iframe) {
50
50
  div.style.bottom = 0;
51
51
  div.style.width = '100vw';
52
52
  div.style.height = '100vh';
53
- div.style.backgroundColor = 'black';
53
+ div.style.backgroundColor = 'rgba(0, 0, 0, 0.85)';
54
54
  div.style.color = '#E8E8E8';
55
55
  div.style.fontFamily = 'Menlo, Consolas, monospace';
56
56
  div.style.fontSize = 'large';
@@ -83,7 +83,7 @@ function ensureOverlayDivExists(onOverlayDivReady) {
83
83
  }
84
84
 
85
85
  // Create iframe and, when it is ready, a div inside it.
86
- overlayIframe = createOverlayIframe(() => {
86
+ overlayIframe = createOverlayIframe(function cb() {
87
87
  overlayDiv = addOverlayDivTo(overlayIframe);
88
88
  // Now we can talk!
89
89
  lastOnOverlayDivReady(overlayDiv);
@@ -96,13 +96,11 @@ function ensureOverlayDivExists(onOverlayDivReady) {
96
96
  }
97
97
 
98
98
  function showMessageOverlay(message) {
99
- ensureOverlayDivExists((div) => {
99
+ ensureOverlayDivExists(function cb(div) {
100
100
  // Make it look similar to our terminal.
101
- div.innerHTML =
102
- `<span style="color: #${
103
- colors.red
104
- }">Failed to compile.</span><br><br>${
105
- ansiHTML(entities.encode(message))}`;
101
+ div.innerHTML = '<span style="color: #' + colors.red +
102
+ '">Failed to compile.</span><br><br>' +
103
+ ansiHTML(entities.encode(message));
106
104
  });
107
105
  }
108
106
 
package/client/socket.js CHANGED
@@ -26,7 +26,7 @@ function socket(url, handlers) {
26
26
  const retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
27
27
  retries += 1;
28
28
 
29
- setTimeout(() => {
29
+ setTimeout(function cb() {
30
30
  socket(url, handlers);
31
31
  }, retryInMs);
32
32
  }
package/lib/Server.js CHANGED
@@ -103,14 +103,13 @@ function Server(compiler, options) {
103
103
 
104
104
  app.get('/webpack-dev-server', (req, res) => {
105
105
  res.setHeader('Content-Type', 'text/html');
106
- /* eslint-disable quotes */
107
106
  res.write('<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>');
108
- const outputPath = this.middleware.getFilenameFromUrl(options.publicPath || "/");
107
+ const outputPath = this.middleware.getFilenameFromUrl(options.publicPath || '/');
109
108
  const filesystem = this.middleware.fileSystem;
110
109
 
111
110
  function writeDirectory(baseUrl, basePath) {
112
111
  const content = filesystem.readdirSync(basePath);
113
- res.write("<ul>");
112
+ res.write('<ul>');
114
113
  content.forEach((item) => {
115
114
  const p = `${basePath}/${item}`;
116
115
  if (filesystem.statSync(p).isFile()) {
@@ -139,9 +138,8 @@ function Server(compiler, options) {
139
138
  res.write('</li>');
140
139
  }
141
140
  });
142
- res.write("</ul>");
141
+ res.write('</ul>');
143
142
  }
144
- /* eslint-enable quotes */
145
143
  writeDirectory(options.publicPath || '/', outputPath);
146
144
  res.end('</body></html>');
147
145
  });
@@ -323,11 +321,19 @@ function Server(compiler, options) {
323
321
  }
324
322
  },
325
323
 
324
+ before: () => {
325
+ if (typeof options.before === 'function') { options.before(app, this); }
326
+ },
327
+
326
328
  middleware: () => {
327
329
  // include our middleware to ensure it is able to handle '/index.html' request after redirect
328
330
  app.use(this.middleware);
329
331
  },
330
332
 
333
+ after: () => {
334
+ if (typeof options.after === 'function') { options.after(app, this); }
335
+ },
336
+
331
337
  headers: () => {
332
338
  app.all('*', this.setContentHeaders.bind(this));
333
339
  },
@@ -337,11 +343,14 @@ function Server(compiler, options) {
337
343
  },
338
344
 
339
345
  setup: () => {
340
- if (typeof options.setup === 'function') { options.setup(app, this); }
346
+ if (typeof options.setup === 'function') {
347
+ log('The `setup` option is deprecated and will be removed in v3. Please update your config to use `before`');
348
+ options.setup(app, this);
349
+ }
341
350
  }
342
351
  };
343
352
 
344
- const defaultFeatures = ['setup', 'headers', 'middleware'];
353
+ const defaultFeatures = ['before', 'setup', 'headers', 'middleware'];
345
354
  if (options.proxy) { defaultFeatures.push('proxy', 'middleware'); }
346
355
  if (contentBase !== false) { defaultFeatures.push('contentBaseFiles'); }
347
356
  if (options.watchContentBase) { defaultFeatures.push('watchContentBase'); }
@@ -353,6 +362,7 @@ function Server(compiler, options) {
353
362
  if (contentBase !== false) { defaultFeatures.push('contentBaseIndex'); }
354
363
  // compress is placed last and uses unshift so that it will be the first middleware used
355
364
  if (options.compress) { defaultFeatures.unshift('compress'); }
365
+ if (options.after) { defaultFeatures.push('after'); }
356
366
 
357
367
  (options.features || defaultFeatures).forEach((feature) => {
358
368
  features[feature]();
@@ -624,13 +634,11 @@ Server.prototype.serveMagicHtml = function (req, res, next) {
624
634
  try {
625
635
  if (!this.middleware.fileSystem.statSync(this.middleware.getFilenameFromUrl(`${_path}.js`)).isFile()) { return next(); }
626
636
  // Serve a page that executes the javascript
627
- /* eslint-disable quotes */
628
637
  res.write('<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><script type="text/javascript" charset="utf-8" src="');
629
638
  res.write(_path);
630
639
  res.write('.js');
631
- res.write(req._parsedUrl.search || "");
640
+ res.write(req._parsedUrl.search || '');
632
641
  res.end('"></script></body></html>');
633
- /* eslint-enable quotes */
634
642
  } catch (e) {
635
643
  return next();
636
644
  }
@@ -64,9 +64,6 @@
64
64
  },
65
65
  "headers": {
66
66
  "description": "Response headers that are added to each response.",
67
- "additionalProperties": {
68
- "type": "string"
69
- },
70
67
  "type": "object"
71
68
  },
72
69
  "clientLogLevel": {
@@ -274,6 +271,14 @@
274
271
  "description": "Exposes the Express server to add custom middleware or routes.",
275
272
  "instanceof": "Function"
276
273
  },
274
+ "before": {
275
+ "description": "Exposes the Express server to add custom middleware or routes before webpack-dev-middleware will be added.",
276
+ "instanceof": "Function"
277
+ },
278
+ "after": {
279
+ "description": "Exposes the Express server to add custom middleware or routes after webpack-dev-middleware got added.",
280
+ "instanceof": "Function"
281
+ },
277
282
  "stats": {
278
283
  "description": "Decides what bundle information is displayed.",
279
284
  "anyOf": [
package/lib/polyfills.js CHANGED
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  /* polyfills for Node 4.8.x users */
4
- /* eslint no-extend-native: off, global-require: off */
5
4
 
6
5
  // internal-ip@2.x uses [].includes
7
- if (!Array.prototype.includes) {
8
- Array.prototype.includes = require('array-includes');
9
- }
6
+ const includes = require('array-includes');
7
+
8
+ includes.shim();
@@ -10,8 +10,12 @@ module.exports = function createDomain(options, listeningApp) {
10
10
  const port = options.socket ? 0 : appPort;
11
11
  const hostname = options.useLocalIp ? internalIp.v4() : options.host;
12
12
 
13
+ // use explicitly defined public url (prefix with protocol if not explicitly given)
14
+ if (options.public) {
15
+ return /^[a-zA-Z]+:\/\//.test(options.public) ? `${options.public}` : `${protocol}://${options.public}`;
16
+ }
13
17
  // the formatted domain (url without path) of the webpack server
14
- return options.public ? `${protocol}://${options.public}` : url.format({
18
+ return url.format({
15
19
  protocol,
16
20
  hostname,
17
21
  port
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "2.8.1",
3
+ "version": "2.9.2",
4
4
  "description": "Serves a webpack app. Updates the browser on changes.",
5
5
  "license": "MIT",
6
6
  "repository": "webpack/webpack-dev-server",
@@ -50,7 +50,7 @@
50
50
  "express": "^4.13.3",
51
51
  "html-entities": "^1.2.0",
52
52
  "http-proxy-middleware": "~0.17.4",
53
- "internal-ip": "^2.0.2",
53
+ "internal-ip": "1.2.0",
54
54
  "ip": "^1.1.5",
55
55
  "loglevel": "^1.4.1",
56
56
  "opn": "^5.1.0",
@@ -60,10 +60,10 @@
60
60
  "sockjs": "0.3.18",
61
61
  "sockjs-client": "1.1.4",
62
62
  "spdy": "^3.4.1",
63
- "strip-ansi": "^4.0.0",
63
+ "strip-ansi": "^3.0.1",
64
64
  "supports-color": "^4.2.1",
65
65
  "webpack-dev-middleware": "^1.11.0",
66
- "yargs": "^8.0.2"
66
+ "yargs": "^6.6.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "codecov.io": "^0.1.6",
package/ssl/server.pem ADDED
@@ -0,0 +1,46 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEowIBAAKCAQEAtoS4CpKBMmqAuoOv0P+RNWctGnwjxLmB/LSNy4rGHiF+f+t/
3
+ qr5OWSeZbns/Qn6XMRaC4PaZkE0Y8Gpp8ZzbQPSaOaTeK8N8ZvnfwEcjJApOgW/k
4
+ ZJwBx6GfqeRy6ecXpMWZjkiKLT+cz0g9wZDFQBWEOzOjWTk9Oy8ptF9babi2Rbd9
5
+ WGFMGEVZI8OI4grP/KDHs0xu20fkeefnJ6CIPjVdmcCF3JhF5Cbh856RID8MunST
6
+ lArTY9kWWCtTyI4PFik3xUrTZ48CFduwb+xOYrBysQJcrZxZlbHMfMrIdVdmGhz9
7
+ WM8OdgfcT3tsqnSS5HyISpt1YtGFcG7HQAF1fwIDAQABAoIBACPyx/ztFh1D9M7H
8
+ mR1k+Mi35Z5NzQ22K/AF79ejIZpVpoCzdZW/ndbZgdLM24zROh4k/OoqJ9z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