webpack-dev-server 3.3.1 → 3.5.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 +60 -1
- package/README.md +17 -10
- package/bin/options.js +7 -1
- package/bin/webpack-dev-server.js +22 -99
- package/client/index.bundle.js +1 -1
- package/client/index.js +89 -116
- package/client/live.bundle.js +10 -10
- package/client/sockjs.bundle.js +1 -1
- package/client/utils/getCurrentScriptSource.js +22 -0
- package/client/utils/reloadApp.js +54 -0
- package/client/utils/sendMessage.js +14 -0
- package/lib/Server.js +559 -599
- package/lib/options.json +246 -177
- package/lib/servers/BaseServer.js +9 -0
- package/lib/servers/SockJSServer.js +64 -0
- package/lib/servers/WebsocketServer.js +8 -0
- package/lib/utils/addEntries.js +45 -14
- package/lib/utils/createCertificate.js +2 -2
- package/lib/utils/createConfig.js +16 -0
- package/lib/utils/defaultPort.js +3 -0
- package/lib/utils/findPort.js +22 -29
- package/lib/utils/getCertificate.js +45 -0
- package/lib/utils/processOptions.js +29 -0
- package/lib/utils/routes.js +103 -0
- package/lib/utils/runOpen.js +21 -0
- package/lib/utils/setupExitSignals.js +21 -0
- package/lib/utils/status.js +3 -14
- package/package.json +58 -61
- package/client/webpack.config.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
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.5.1](https://github.com/webpack/webpack-dev-server/compare/v3.5.0...v3.5.1) (2019-06-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* allow passing promise function of webpack.config.js ([#1947](https://github.com/webpack/webpack-dev-server/issues/1947)) ([8cf1053](https://github.com/webpack/webpack-dev-server/commit/8cf1053))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.5.0](https://github.com/webpack/webpack-dev-server/compare/v3.4.1...v3.5.0) (2019-05-31)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add client code for `electron-renderer` target ([#1935](https://github.com/webpack/webpack-dev-server/issues/1935)) ([9297988](https://github.com/webpack/webpack-dev-server/commit/9297988))
|
|
20
|
+
* add client code for `node-webkit` target ([#1942](https://github.com/webpack/webpack-dev-server/issues/1942)) ([c6b2b1f](https://github.com/webpack/webpack-dev-server/commit/c6b2b1f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **server:** `onListening` option ([#1930](https://github.com/webpack/webpack-dev-server/issues/1930)) ([61d0cdf](https://github.com/webpack/webpack-dev-server/commit/61d0cdf))
|
|
26
|
+
* **server:** add callback support for invalidate ([#1900](https://github.com/webpack/webpack-dev-server/issues/1900)) ([cd218ef](https://github.com/webpack/webpack-dev-server/commit/cd218ef))
|
|
27
|
+
* **server:** add `WEBPACK_DEV_SERVER` env variable ([#1929](https://github.com/webpack/webpack-dev-server/issues/1929)) ([856169e](https://github.com/webpack/webpack-dev-server/commit/856169e))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### [3.4.1](https://github.com/webpack/webpack-dev-server/compare/v3.4.0...v3.4.1) (2019-05-17)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* add none and warning to clientLogLevel ([#1901](https://github.com/webpack/webpack-dev-server/issues/1901)) ([0ae9be8](https://github.com/webpack/webpack-dev-server/commit/0ae9be8))
|
|
37
|
+
* broken hot reload ([#1903](https://github.com/webpack/webpack-dev-server/issues/1903)) ([6a444cd](https://github.com/webpack/webpack-dev-server/commit/6a444cd))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [3.4.0](https://github.com/webpack/webpack-dev-server/compare/v3.3.1...v3.4.0) (2019-05-17)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* don't use self.location.port ([#1838](https://github.com/webpack/webpack-dev-server/issues/1838)) ([6d31984](https://github.com/webpack/webpack-dev-server/commit/6d31984))
|
|
47
|
+
* do not include config files in dist ([#1883](https://github.com/webpack/webpack-dev-server/issues/1883)) ([c535bb2](https://github.com/webpack/webpack-dev-server/commit/c535bb2))
|
|
48
|
+
* only add client entry to web targets ([#1775](https://github.com/webpack/webpack-dev-server/issues/1775)) ([cf4d0d0](https://github.com/webpack/webpack-dev-server/commit/cf4d0d0))
|
|
49
|
+
* update clientLogLevel to match docs and error ([#1825](https://github.com/webpack/webpack-dev-server/issues/1825)) ([7f52bbf](https://github.com/webpack/webpack-dev-server/commit/7f52bbf))
|
|
50
|
+
* add errors-warnings preset ([#1895](https://github.com/webpack/webpack-dev-server/issues/1895)) ([2a81ad2](https://github.com/webpack/webpack-dev-server/commit/2a81ad2))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
* added injectClient option ([#1775](https://github.com/webpack/webpack-dev-server/issues/1775)) ([cf4d0d0](https://github.com/webpack/webpack-dev-server/commit/cf4d0d0))
|
|
56
|
+
* added injectHot option ([#1775](https://github.com/webpack/webpack-dev-server/issues/1775)) ([cf4d0d0](https://github.com/webpack/webpack-dev-server/commit/cf4d0d0))
|
|
57
|
+
* added sockPort option ([#1792](https://github.com/webpack/webpack-dev-server/issues/1792)) ([58d1682](https://github.com/webpack/webpack-dev-server/commit/58d1682))
|
|
58
|
+
* added sockHost option ([#1858](https://github.com/webpack/webpack-dev-server/issues/1858)) ([f47dff2](https://github.com/webpack/webpack-dev-server/commit/f47dff2))
|
|
59
|
+
* support HEAD method ([#1875](https://github.com/webpack/webpack-dev-server/issues/1875)) ([c2360e4](https://github.com/webpack/webpack-dev-server/commit/c2360e4))
|
|
60
|
+
* added liveReload option ([#1889](https://github.com/webpack/webpack-dev-server/issues/1889)) ([fc4fe32](https://github.com/webpack/webpack-dev-server/commit/fc4fe32))
|
|
61
|
+
* update express to 4.17 version
|
|
62
|
+
|
|
63
|
+
|
|
5
64
|
## [3.3.1](https://github.com/webpack/webpack-dev-server/compare/v3.3.0...v3.3.1) (2019-04-09)
|
|
6
65
|
|
|
7
66
|
|
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
[![tests][tests]][tests-url]
|
|
11
11
|
[![coverage][cover]][cover-url]
|
|
12
12
|
[![chat][chat]][chat-url]
|
|
13
|
+
[![downloads][downloads]][npm-url]
|
|
14
|
+
[![contributors][contributors]][contributors-url]
|
|
13
15
|
|
|
14
16
|
# webpack-dev-server
|
|
15
17
|
|
|
@@ -21,14 +23,16 @@ fast in-memory access to the webpack assets.
|
|
|
21
23
|
|
|
22
24
|
## Table of Contents
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
- [Getting Started](#getting-started)
|
|
27
|
+
- [Usage](#usage)
|
|
28
|
+
- [With the CLI](#with-the-cli)
|
|
29
|
+
- [With NPM Scripts](#with-npm-scripts)
|
|
30
|
+
- [The Result](#the-result)
|
|
31
|
+
- [Browser Support](#browser-support)
|
|
32
|
+
- [Support](#support)
|
|
33
|
+
- [Contributing](#contributing)
|
|
34
|
+
- [Attribution](#attribution)
|
|
35
|
+
- [License](#license)
|
|
32
36
|
|
|
33
37
|
## Getting Started
|
|
34
38
|
|
|
@@ -142,8 +146,8 @@ This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/
|
|
|
142
146
|
[node-url]: https://nodejs.org
|
|
143
147
|
[deps]: https://david-dm.org/webpack/webpack-dev-server.svg
|
|
144
148
|
[deps-url]: https://david-dm.org/webpack/webpack-dev-server
|
|
145
|
-
[tests]:
|
|
146
|
-
[tests-url]: https://
|
|
149
|
+
[tests]: https://dev.azure.com/webpack/webpack-dev-server/_apis/build/status/webpack.webpack-dev-server?branchName=master
|
|
150
|
+
[tests-url]: https://dev.azure.com/webpack/webpack-dev-server/_build/latest?definitionId=7&branchName=master
|
|
147
151
|
[cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
|
|
148
152
|
[cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
|
|
149
153
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
@@ -154,3 +158,6 @@ This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/
|
|
|
154
158
|
[stack-url]: https://stackoverflow.com/questions/tagged/webpack-dev-server
|
|
155
159
|
[uglify-url]: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
|
|
156
160
|
[wjo-url]: https://github.com/webpack/webpack.js.org
|
|
161
|
+
[downloads]: https://img.shields.io/npm/dm/webpack-dev-server.svg
|
|
162
|
+
[contributors-url]: https://github.com/webpack/webpack-dev-server/graphs/contributors
|
|
163
|
+
[contributors]: https://img.shields.io/github/contributors/webpack/webpack-dev-server.svg
|
package/bin/options.js
CHANGED
|
@@ -21,6 +21,11 @@ const options = {
|
|
|
21
21
|
type: 'boolean',
|
|
22
22
|
describe: 'Lazy',
|
|
23
23
|
},
|
|
24
|
+
liveReload: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
describe: 'Enables/Disables live reloading on changing files',
|
|
27
|
+
default: true,
|
|
28
|
+
},
|
|
24
29
|
serveIndex: {
|
|
25
30
|
type: 'boolean',
|
|
26
31
|
describe: 'Enables/Disables serveIndex middleware',
|
|
@@ -85,7 +90,8 @@ const options = {
|
|
|
85
90
|
type: 'string',
|
|
86
91
|
group: DISPLAY_GROUP,
|
|
87
92
|
default: 'info',
|
|
88
|
-
describe:
|
|
93
|
+
describe:
|
|
94
|
+
'Log level in the browser (trace, debug, info, warn, error or silent)',
|
|
89
95
|
},
|
|
90
96
|
https: {
|
|
91
97
|
type: 'boolean',
|
|
@@ -2,52 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable
|
|
6
|
-
import/order,
|
|
7
|
-
no-shadow,
|
|
8
|
-
no-console
|
|
9
|
-
*/
|
|
10
|
-
const debug = require('debug')('webpack-dev-server');
|
|
5
|
+
/* eslint-disable no-shadow, no-console */
|
|
11
6
|
|
|
12
7
|
const fs = require('fs');
|
|
13
8
|
const net = require('net');
|
|
14
|
-
|
|
9
|
+
const debug = require('debug')('webpack-dev-server');
|
|
15
10
|
const importLocal = require('import-local');
|
|
16
|
-
|
|
17
11
|
const yargs = require('yargs');
|
|
18
12
|
const webpack = require('webpack');
|
|
19
|
-
|
|
20
|
-
const options = require('./options');
|
|
21
13
|
const Server = require('../lib/Server');
|
|
22
|
-
|
|
14
|
+
const setupExitSignals = require('../lib/utils/setupExitSignals');
|
|
23
15
|
const colors = require('../lib/utils/colors');
|
|
24
|
-
const
|
|
25
|
-
const createDomain = require('../lib/utils/createDomain');
|
|
16
|
+
const processOptions = require('../lib/utils/processOptions');
|
|
26
17
|
const createLogger = require('../lib/utils/createLogger');
|
|
27
|
-
const defaultTo = require('../lib/utils/defaultTo');
|
|
28
18
|
const findPort = require('../lib/utils/findPort');
|
|
29
19
|
const getVersions = require('../lib/utils/getVersions');
|
|
30
|
-
const
|
|
31
|
-
const status = require('../lib/utils/status');
|
|
32
|
-
const tryParseInt = require('../lib/utils/tryParseInt');
|
|
20
|
+
const options = require('./options');
|
|
33
21
|
|
|
34
22
|
let server;
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
signals.forEach((signal) => {
|
|
39
|
-
process.on(signal, () => {
|
|
40
|
-
if (server) {
|
|
41
|
-
server.close(() => {
|
|
42
|
-
// eslint-disable-next-line no-process-exit
|
|
43
|
-
process.exit();
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
// eslint-disable-next-line no-process-exit
|
|
47
|
-
process.exit();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
24
|
+
setupExitSignals(server);
|
|
51
25
|
|
|
52
26
|
// Prefer the local installation of webpack-dev-server
|
|
53
27
|
if (importLocal(__filename)) {
|
|
@@ -106,36 +80,6 @@ const config = require(convertArgvPath)(yargs, argv, {
|
|
|
106
80
|
outputFilename: '/bundle.js',
|
|
107
81
|
});
|
|
108
82
|
|
|
109
|
-
// Taken out of yargs because we must know if
|
|
110
|
-
// it wasn't given by the user, in which case
|
|
111
|
-
// we should use portfinder.
|
|
112
|
-
const DEFAULT_PORT = 8080;
|
|
113
|
-
|
|
114
|
-
// Try to find unused port and listen on it for 3 times,
|
|
115
|
-
// if port is not specified in options.
|
|
116
|
-
// Because NaN == null is false, defaultTo fails if parseInt returns NaN
|
|
117
|
-
// so the tryParseInt function is introduced to handle NaN
|
|
118
|
-
const defaultPortRetry = defaultTo(
|
|
119
|
-
tryParseInt(process.env.DEFAULT_PORT_RETRY),
|
|
120
|
-
3
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
function processOptions(config) {
|
|
124
|
-
// processOptions {Promise}
|
|
125
|
-
if (typeof config.then === 'function') {
|
|
126
|
-
config.then(processOptions).catch((err) => {
|
|
127
|
-
console.error(err.stack || err);
|
|
128
|
-
// eslint-disable-next-line no-process-exit
|
|
129
|
-
process.exit();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const options = createConfig(config, argv, { port: DEFAULT_PORT });
|
|
136
|
-
startDevServer(config, options);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
83
|
function startDevServer(config, options) {
|
|
140
84
|
const log = createLogger(options);
|
|
141
85
|
|
|
@@ -159,11 +103,6 @@ function startDevServer(config, options) {
|
|
|
159
103
|
}).apply(compiler);
|
|
160
104
|
}
|
|
161
105
|
|
|
162
|
-
const suffix =
|
|
163
|
-
options.inline !== false || options.lazy === true
|
|
164
|
-
? '/'
|
|
165
|
-
: '/webpack-dev-server/';
|
|
166
|
-
|
|
167
106
|
try {
|
|
168
107
|
server = new Server(compiler, options, log);
|
|
169
108
|
} catch (err) {
|
|
@@ -204,6 +143,7 @@ function startDevServer(config, options) {
|
|
|
204
143
|
if (err) {
|
|
205
144
|
throw err;
|
|
206
145
|
}
|
|
146
|
+
|
|
207
147
|
// chmod 666 (rw rw rw)
|
|
208
148
|
const READ_WRITE = 438;
|
|
209
149
|
|
|
@@ -211,41 +151,24 @@ function startDevServer(config, options) {
|
|
|
211
151
|
if (err) {
|
|
212
152
|
throw err;
|
|
213
153
|
}
|
|
214
|
-
|
|
215
|
-
const uri = createDomain(options, server.listeningApp) + suffix;
|
|
216
|
-
|
|
217
|
-
status(uri, options, log, argv.color);
|
|
218
154
|
});
|
|
219
155
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
156
|
+
} else {
|
|
157
|
+
findPort(options.port)
|
|
158
|
+
.then((port) => {
|
|
159
|
+
options.port = port;
|
|
160
|
+
server.listen(options.port, options.host, (err) => {
|
|
161
|
+
if (err) {
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
})
|
|
166
|
+
.catch((err) => {
|
|
226
167
|
throw err;
|
|
227
|
-
}
|
|
228
|
-
if (options.bonjour) {
|
|
229
|
-
runBonjour(options);
|
|
230
|
-
}
|
|
231
|
-
const uri = createDomain(options, server.listeningApp) + suffix;
|
|
232
|
-
status(uri, options, log, argv.color);
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
if (options.port) {
|
|
237
|
-
startServer();
|
|
238
|
-
return;
|
|
168
|
+
});
|
|
239
169
|
}
|
|
240
|
-
|
|
241
|
-
// only run port finder if no port as been specified
|
|
242
|
-
findPort(server, DEFAULT_PORT, defaultPortRetry, (err, port) => {
|
|
243
|
-
if (err) {
|
|
244
|
-
throw err;
|
|
245
|
-
}
|
|
246
|
-
options.port = port;
|
|
247
|
-
startServer();
|
|
248
|
-
});
|
|
249
170
|
}
|
|
250
171
|
|
|
251
|
-
processOptions(config)
|
|
172
|
+
processOptions(config, argv, (config, options) => {
|
|
173
|
+
startDevServer(config, options);
|
|
174
|
+
});
|