webpack-dev-server 3.2.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -2,21 +2,15 @@
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
- # [3.2.0](https://github.com/webpack/webpack-dev-server/compare/v3.1.14...v3.2.0) (2019-02-20)
5
+ ## [3.2.1](https://github.com/webpack/webpack-dev-server/compare/v3.2.0...v3.2.1) (2019-02-25)
6
6
 
7
7
 
8
8
  ### Bug Fixes
9
9
 
10
- * allow single object proxy config ([#1633](https://github.com/webpack/webpack-dev-server/issues/1633)) ([252ea4f](https://github.com/webpack/webpack-dev-server/commit/252ea4f))
11
- * SPDY fails in node >= 11.1.0 ([#1660](https://github.com/webpack/webpack-dev-server/issues/1660)) ([b92e5fd](https://github.com/webpack/webpack-dev-server/commit/b92e5fd))
12
-
13
-
14
- ### Features
15
-
16
- * add `sockPath` option (`options.sockPath`) ([#1553](https://github.com/webpack/webpack-dev-server/issues/1553)) ([4bf1f76](https://github.com/webpack/webpack-dev-server/commit/4bf1f76))
17
- * allow to use `ca`, `pfx`, `key` and `cert` as string ([#1542](https://github.com/webpack/webpack-dev-server/issues/1542)) ([0b89fd9](https://github.com/webpack/webpack-dev-server/commit/0b89fd9))
18
- * automatically add the HMR plugin when hot or hotOnly is enabled ([#1612](https://github.com/webpack/webpack-dev-server/issues/1612)) ([178e6cc](https://github.com/webpack/webpack-dev-server/commit/178e6cc))
19
- * set `development` mode by default when unspecified ([#1653](https://github.com/webpack/webpack-dev-server/issues/1653)) ([5ea376b](https://github.com/webpack/webpack-dev-server/commit/5ea376b))
10
+ * deprecation message about `setup` now warning about `v4` ([#1684](https://github.com/webpack/webpack-dev-server/issues/1684)) ([523a6ec](https://github.com/webpack/webpack-dev-server/commit/523a6ec))
11
+ * **regression:** allow `ca`, `key` and `cert` will be string ([#1676](https://github.com/webpack/webpack-dev-server/issues/1676)) ([b8d5c1e](https://github.com/webpack/webpack-dev-server/commit/b8d5c1e))
12
+ * **regression:** handle `key`, `cert`, `cacert` and `pfx` in CLI ([#1688](https://github.com/webpack/webpack-dev-server/issues/1688)) ([4b2076c](https://github.com/webpack/webpack-dev-server/commit/4b2076c))
13
+ * **regression:** problem with `idb-connector` after update `internal-ip` ([#1691](https://github.com/webpack/webpack-dev-server/issues/1691)) ([eb48691](https://github.com/webpack/webpack-dev-server/commit/eb48691))
20
14
 
21
15
 
22
16
 
@@ -4,14 +4,8 @@
4
4
 
5
5
  /* eslint-disable
6
6
  import/order,
7
- import/no-extraneous-dependencies,
8
- global-require,
9
7
  no-shadow,
10
- no-console,
11
- multiline-ternary,
12
- arrow-parens,
13
- array-bracket-spacing,
14
- space-before-function-paren
8
+ no-console
15
9
  */
16
10
  const debug = require('debug')('webpack-dev-server');
17
11
 
@@ -26,14 +20,16 @@ const webpack = require('webpack');
26
20
 
27
21
  const options = require('./options');
28
22
 
29
- const { colors, status, version, bonjour } = require('./utils');
30
-
31
23
  const Server = require('../lib/Server');
32
24
 
33
25
  const addEntries = require('../lib/utils/addEntries');
26
+ const colors = require('../lib/utils/colors');
27
+ const createConfig = require('../lib/utils/createConfig');
34
28
  const createDomain = require('../lib/utils/createDomain');
35
29
  const createLogger = require('../lib/utils/createLogger');
36
- const createConfig = require('../lib/utils/createConfig');
30
+ const getVersions = require('../lib/utils/getVersions');
31
+ const runBonjour = require('../lib/utils/runBonjour');
32
+ const status = require('../lib/utils/status');
37
33
 
38
34
  let server;
39
35
 
@@ -74,17 +70,20 @@ try {
74
70
  }
75
71
 
76
72
  yargs.usage(
77
- `${version()}\nUsage: https://webpack.js.org/configuration/dev-server/`
73
+ `${getVersions()}\nUsage: https://webpack.js.org/configuration/dev-server/`
78
74
  );
79
75
 
76
+ // eslint-disable-next-line import/no-extraneous-dependencies
80
77
  require('webpack-cli/bin/config-yargs')(yargs);
78
+
81
79
  // It is important that this is done after the webpack yargs config,
82
80
  // so it overrides webpack's version info.
83
- yargs.version(version());
81
+ yargs.version(getVersions());
84
82
  yargs.options(options);
85
83
 
86
84
  const argv = yargs.argv;
87
85
 
86
+ // eslint-disable-next-line import/no-extraneous-dependencies
88
87
  const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
89
88
  outputFilename: '/bundle.js',
90
89
  });
@@ -217,7 +216,7 @@ function startDevServer(config, options) {
217
216
  }
218
217
 
219
218
  if (options.bonjour) {
220
- bonjour(options);
219
+ runBonjour(options);
221
220
  }
222
221
 
223
222
  const uri = createDomain(options, server.listeningApp) + suffix;
package/lib/Server.js CHANGED
@@ -4,10 +4,7 @@
4
4
  import/order,
5
5
  no-shadow,
6
6
  no-undefined,
7
- func-names,
8
- multiline-ternary,
9
- array-bracket-spacing,
10
- space-before-function-paren
7
+ func-names
11
8
  */
12
9
  const fs = require('fs');
13
10
  const path = require('path');
@@ -505,7 +502,7 @@ class Server {
505
502
  setup: () => {
506
503
  if (typeof options.setup === 'function') {
507
504
  this.log.warn(
508
- 'The `setup` option is deprecated and will be removed in v3. Please update your config to use `before`'
505
+ 'The `setup` option is deprecated and will be removed in v4. Please update your config to use `before`'
509
506
  );
510
507
 
511
508
  options.setup(app, this);
@@ -570,8 +567,21 @@ class Server {
570
567
  const value = options.https[property];
571
568
  const isBuffer = value instanceof Buffer;
572
569
 
573
- if (value && !isBuffer && fs.lstatSync(value).isFile()) {
574
- options.https[property] = fs.readFileSync(path.resolve(value));
570
+ if (value && !isBuffer) {
571
+ let stats = null;
572
+
573
+ try {
574
+ stats = fs.lstatSync(value).isFile();
575
+ } catch (error) {
576
+ // ignore error
577
+ }
578
+
579
+ if (stats) {
580
+ // It is file
581
+ options.https[property] = fs.readFileSync(path.resolve(value));
582
+ } else {
583
+ options.https[property] = value;
584
+ }
575
585
  }
576
586
  }
577
587
 
@@ -610,7 +620,7 @@ class Server {
610
620
  const pems = createCertificate(attrs);
611
621
 
612
622
  fs.writeFileSync(certPath, pems.private + pems.cert, {
613
- encoding: 'utf-8',
623
+ encoding: 'utf8',
614
624
  });
615
625
  }
616
626
 
@@ -689,7 +699,10 @@ class Server {
689
699
  return true;
690
700
  }
691
701
 
692
- if (!headerToCheck) headerToCheck = 'host';
702
+ if (!headerToCheck) {
703
+ headerToCheck = 'host';
704
+ }
705
+
693
706
  // get the Host header and extract hostname
694
707
  // we don't care about port not matching
695
708
  const hostHeader = headers[headerToCheck];
@@ -723,7 +736,9 @@ class Server {
723
736
  for (let hostIdx = 0; hostIdx < this.allowedHosts.length; hostIdx++) {
724
737
  const allowedHost = this.allowedHosts[hostIdx];
725
738
 
726
- if (allowedHost === hostname) return true;
739
+ if (allowedHost === hostname) {
740
+ return true;
741
+ }
727
742
 
728
743
  // support "." as a subdomain wildcard
729
744
  // e.g. ".example.com" will allow "example.com", "www.example.com", "subdomain.example.com", etc
@@ -765,7 +780,7 @@ class Server {
765
780
  listen(port, hostname, fn) {
766
781
  this.hostname = hostname;
767
782
 
768
- const returnValue = this.listeningApp.listen(port, hostname, (err) => {
783
+ return this.listeningApp.listen(port, hostname, (err) => {
769
784
  const socket = sockjs.createServer({
770
785
  // Use provided up-to-date sockjs-client
771
786
  sockjs_url: '/__webpack_dev_server__/sockjs.bundle.js',
@@ -836,8 +851,6 @@ class Server {
836
851
  fn.call(this.listeningApp, err);
837
852
  }
838
853
  });
839
-
840
- return returnValue;
841
854
  }
842
855
 
843
856
  close(cb) {
@@ -1,11 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /* eslint-disable
4
- no-shadow,
5
- no-param-reassign,
6
- array-bracket-spacing,
7
- space-before-function-paren
8
- */
9
3
  const webpack = require('webpack');
10
4
  const createDomain = require('./createDomain');
11
5
 
@@ -50,6 +44,7 @@ function addEntries(config, options, server) {
50
44
  return entries.concat(entry);
51
45
  };
52
46
 
47
+ // eslint-disable-next-line no-shadow
53
48
  [].concat(config).forEach((config) => {
54
49
  config.entry = prependEntry(config.entry || './src');
55
50
 
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ const colors = {
4
+ info(useColor, msg) {
5
+ if (useColor) {
6
+ // Make text blue and bold, so it *pops*
7
+ return `\u001b[1m\u001b[34m${msg}\u001b[39m\u001b[22m`;
8
+ }
9
+
10
+ return msg;
11
+ },
12
+ error(useColor, msg) {
13
+ if (useColor) {
14
+ // Make text red and bold, so it *pops*
15
+ return `\u001b[1m\u001b[31m${msg}\u001b[39m\u001b[22m`;
16
+ }
17
+
18
+ return msg;
19
+ },
20
+ };
21
+
22
+ module.exports = colors;
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /* eslint-disable
4
- space-before-function-paren
5
- */
6
3
  const selfsigned = require('selfsigned');
7
4
 
8
5
  function createCertificate(attrs) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('path');
4
- const { defaultTo } = require('../../bin/utils');
4
+ const defaultTo = require('./defaultTo');
5
5
 
6
6
  function createConfig(config, argv, { port }) {
7
7
  const firstWpOpt = Array.isArray(config) ? config[0] : config;
@@ -14,12 +14,12 @@ function createConfig(config, argv, { port }) {
14
14
  options.bonjour = true;
15
15
  }
16
16
 
17
- if (argv.host !== 'localhost' || !options.host) {
17
+ if (argv.host && (argv.host !== 'localhost' || !options.host)) {
18
18
  options.host = argv.host;
19
19
  }
20
20
 
21
- if (argv['allowed-hosts']) {
22
- options.allowedHosts = argv['allowed-hosts'].split(',');
21
+ if (argv.allowedHosts) {
22
+ options.allowedHosts = argv.allowedHosts.split(',');
23
23
  }
24
24
 
25
25
  if (argv.public) {
@@ -47,11 +47,11 @@ function createConfig(config, argv, { port }) {
47
47
  }
48
48
  }
49
49
 
50
- if (!options.filename) {
50
+ if (!options.filename && firstWpOpt.output && firstWpOpt.output.filename) {
51
51
  options.filename = firstWpOpt.output && firstWpOpt.output.filename;
52
52
  }
53
53
 
54
- if (!options.watchOptions) {
54
+ if (!options.watchOptions && firstWpOpt.watchOptions) {
55
55
  options.watchOptions = firstWpOpt.watchOptions;
56
56
  }
57
57
 
@@ -64,38 +64,42 @@ function createConfig(config, argv, { port }) {
64
64
  process.stdin.resume();
65
65
  }
66
66
 
67
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
68
+ // We should prefer CLI arg under config, now we always prefer `hot` from `devServer`
67
69
  if (!options.hot) {
68
70
  options.hot = argv.hot;
69
71
  }
70
72
 
73
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
74
+ // We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer`
71
75
  if (!options.hotOnly) {
72
- options.hotOnly = argv['hot-only'];
76
+ options.hotOnly = argv.hotOnly;
73
77
  }
74
78
 
75
- if (!options.clientLogLevel) {
76
- options.clientLogLevel = argv['client-log-level'];
79
+ // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
80
+ // We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
81
+ if (!options.clientLogLevel && argv.clientLogLevel) {
82
+ options.clientLogLevel = argv.clientLogLevel;
77
83
  }
78
84
 
79
- // eslint-disable-next-line
80
- if (options.contentBase === undefined) {
81
- if (argv['content-base']) {
82
- options.contentBase = argv['content-base'];
85
+ if (argv.contentBase) {
86
+ options.contentBase = argv.contentBase;
83
87
 
84
- if (Array.isArray(options.contentBase)) {
85
- options.contentBase = options.contentBase.map((p) => path.resolve(p));
86
- } else if (/^[0-9]$/.test(options.contentBase)) {
87
- options.contentBase = +options.contentBase;
88
- } else if (!/^(https?:)?\/\//.test(options.contentBase)) {
89
- options.contentBase = path.resolve(options.contentBase);
90
- }
91
- // It is possible to disable the contentBase by using
92
- // `--no-content-base`, which results in arg["content-base"] = false
93
- } else if (argv['content-base'] === false) {
94
- options.contentBase = false;
88
+ if (Array.isArray(options.contentBase)) {
89
+ options.contentBase = options.contentBase.map((p) => path.resolve(p));
90
+ } else if (/^[0-9]$/.test(options.contentBase)) {
91
+ options.contentBase = +options.contentBase;
92
+ } else if (!/^(https?:)?\/\//.test(options.contentBase)) {
93
+ options.contentBase = path.resolve(options.contentBase);
95
94
  }
96
95
  }
96
+ // It is possible to disable the contentBase by using
97
+ // `--no-content-base`, which results in arg["content-base"] = false
98
+ else if (argv.contentBase === false) {
99
+ options.contentBase = false;
100
+ }
97
101
 
98
- if (argv['watch-content-base']) {
102
+ if (argv.watchContentBase) {
99
103
  options.watchContentBase = true;
100
104
  }
101
105
 
@@ -108,7 +112,8 @@ function createConfig(config, argv, { port }) {
108
112
 
109
113
  if (
110
114
  typeof options.stats === 'object' &&
111
- typeof options.stats.colors === 'undefined'
115
+ typeof options.stats.colors === 'undefined' &&
116
+ argv.color
112
117
  ) {
113
118
  options.stats = Object.assign({}, options.stats, { colors: argv.color });
114
119
  }
@@ -117,10 +122,12 @@ function createConfig(config, argv, { port }) {
117
122
  options.lazy = true;
118
123
  }
119
124
 
125
+ // TODO remove in `v4`
120
126
  if (!argv.info) {
121
127
  options.noInfo = true;
122
128
  }
123
129
 
130
+ // TODO remove in `v4`
124
131
  if (argv.quiet) {
125
132
  options.quiet = true;
126
133
  }
@@ -129,15 +136,31 @@ function createConfig(config, argv, { port }) {
129
136
  options.https = true;
130
137
  }
131
138
 
132
- if (argv['pfx-passphrase']) {
133
- options.pfxPassphrase = argv['pfx-passphrase'];
139
+ if (argv.key) {
140
+ options.key = argv.key;
141
+ }
142
+
143
+ if (argv.cert) {
144
+ options.cert = argv.cert;
145
+ }
146
+
147
+ if (argv.cacert) {
148
+ options.ca = argv.cacert;
149
+ }
150
+
151
+ if (argv.pfx) {
152
+ options.pfx = argv.pfx;
153
+ }
154
+
155
+ if (argv.pfxPassphrase) {
156
+ options.pfxPassphrase = argv.pfxPassphrase;
134
157
  }
135
158
 
136
159
  if (argv.inline === false) {
137
160
  options.inline = false;
138
161
  }
139
162
 
140
- if (argv['history-api-fallback']) {
163
+ if (argv.historyApiFallback) {
141
164
  options.historyApiFallback = true;
142
165
  }
143
166
 
@@ -145,13 +168,13 @@ function createConfig(config, argv, { port }) {
145
168
  options.compress = true;
146
169
  }
147
170
 
148
- if (argv['disable-host-check']) {
171
+ if (argv.disableHostCheck) {
149
172
  options.disableHostCheck = true;
150
173
  }
151
174
 
152
- if (argv['open-page']) {
175
+ if (argv.openPage) {
153
176
  options.open = true;
154
- options.openPage = argv['open-page'];
177
+ options.openPage = argv.openPage;
155
178
  }
156
179
 
157
180
  if (typeof argv.open !== 'undefined') {
@@ -1,10 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /* eslint-disable
4
- no-nested-ternary,
5
- multiline-ternary,
6
- space-before-function-paren
7
- */
8
3
  const url = require('url');
9
4
  const ip = require('internal-ip');
10
5
 
@@ -14,6 +9,7 @@ function createDomain(options, server) {
14
9
  ? ip.v4.sync() || 'localhost'
15
10
  : options.host;
16
11
 
12
+ // eslint-disable-next-line no-nested-ternary
17
13
  const port = options.socket ? 0 : server ? server.address().port : 0;
18
14
  // use explicitly defined public url
19
15
  // (prefix with protocol if not explicitly given)
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /* eslint-disable
4
- space-before-function-paren
5
- */
6
3
  const log = require('webpack-log');
7
4
 
8
5
  function createLogger(options) {
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function defaultTo(value, def) {
4
+ return value == null ? def : value;
5
+ }
6
+
7
+ module.exports = defaultTo;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable global-require */
4
+
5
+ function getVersions() {
6
+ return (
7
+ `webpack-dev-server ${require('../../package.json').version}\n` +
8
+ `webpack ${require('webpack/package.json').version}`
9
+ );
10
+ }
11
+
12
+ module.exports = getVersions;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ function runBonjour(options) {
4
+ // eslint-disable-next-line global-require
5
+ const bonjour = require('bonjour')();
6
+
7
+ bonjour.publish({
8
+ name: 'Webpack Dev Server',
9
+ port: options.port,
10
+ type: 'http',
11
+ subtypes: ['webpack'],
12
+ });
13
+
14
+ process.on('exit', () => {
15
+ bonjour.unpublishAll(() => {
16
+ bonjour.destroy();
17
+ });
18
+ });
19
+ }
20
+
21
+ module.exports = runBonjour;
@@ -1,44 +1,7 @@
1
1
  'use strict';
2
2
 
3
- /* eslint-disable
4
- no-shadow,
5
- global-require,
6
- multiline-ternary,
7
- array-bracket-spacing,
8
- space-before-function-paren
9
- */
10
3
  const open = require('opn');
11
-
12
- const colors = {
13
- info(useColor, msg) {
14
- if (useColor) {
15
- // Make text blue and bold, so it *pops*
16
- return `\u001b[1m\u001b[34m${msg}\u001b[39m\u001b[22m`;
17
- }
18
-
19
- return msg;
20
- },
21
- error(useColor, msg) {
22
- if (useColor) {
23
- // Make text red and bold, so it *pops*
24
- return `\u001b[1m\u001b[31m${msg}\u001b[39m\u001b[22m`;
25
- }
26
-
27
- return msg;
28
- },
29
- };
30
-
31
- // eslint-disable-next-line
32
- const defaultTo = (value, def) => {
33
- return value == null ? def : value;
34
- };
35
-
36
- function version() {
37
- return (
38
- `webpack-dev-server ${require('../package.json').version}\n` +
39
- `webpack ${require('webpack/package.json').version}`
40
- );
41
- }
4
+ const colors = require('./colors');
42
5
 
43
6
  function status(uri, options, log, useColor) {
44
7
  const contentBase = Array.isArray(options.contentBase)
@@ -96,27 +59,4 @@ function status(uri, options, log, useColor) {
96
59
  }
97
60
  }
98
61
 
99
- function bonjour(options) {
100
- const bonjour = require('bonjour')();
101
-
102
- bonjour.publish({
103
- name: 'Webpack Dev Server',
104
- port: options.port,
105
- type: 'http',
106
- subtypes: ['webpack'],
107
- });
108
-
109
- process.on('exit', () => {
110
- bonjour.unpublishAll(() => {
111
- bonjour.destroy();
112
- });
113
- });
114
- }
115
-
116
- module.exports = {
117
- status,
118
- colors,
119
- version,
120
- bonjour,
121
- defaultTo,
122
- };
62
+ module.exports = status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Serves a webpack app. Updates the browser on changes.",
5
5
  "bin": "bin/webpack-dev-server.js",
6
6
  "main": "lib/Server.js",
@@ -37,7 +37,7 @@
37
37
  "html-entities": "^1.2.0",
38
38
  "http-proxy-middleware": "^0.19.1",
39
39
  "import-local": "^2.0.0",
40
- "internal-ip": "^4.0.0",
40
+ "internal-ip": "^4.2.0",
41
41
  "ip": "^1.1.5",
42
42
  "killable": "^1.0.0",
43
43
  "loglevel": "^1.4.1",
@@ -62,7 +62,7 @@
62
62
  "@babel/core": "^7.2.2",
63
63
  "@babel/preset-env": "^7.3.1",
64
64
  "babel-loader": "^8.0.5",
65
- "copy-webpack-plugin": "^4.5.1",
65
+ "copy-webpack-plugin": "^5.0.0",
66
66
  "css-loader": "^2.1.0",
67
67
  "eslint": "^5.4.0",
68
68
  "eslint-config-prettier": "^4.0.0",
@@ -79,7 +79,7 @@
79
79
  "less": "^3.7.1",
80
80
  "less-loader": "^4.1.0",
81
81
  "lint-staged": "^8.1.1",
82
- "marked": "^0.6.0",
82
+ "marked": "^0.6.1",
83
83
  "nyc": "^13.3.0",
84
84
  "prettier": "^1.16.3",
85
85
  "rimraf": "^2.6.2",