webpack-dev-server 3.1.12 → 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 +32 -0
- package/README.md +13 -7
- package/bin/options.js +33 -31
- package/bin/webpack-dev-server.js +26 -221
- package/client/index.bundle.js +1 -1
- package/client/index.js +58 -36
- package/client/live.bundle.js +3 -3
- package/client/overlay.js +18 -21
- package/client/socket.js +4 -5
- package/client/sockjs.bundle.js +1 -1
- package/client/webpack.config.js +14 -0
- package/lib/Server.js +748 -679
- package/lib/options.json +8 -24
- package/lib/utils/addEntries.js +20 -9
- package/lib/utils/colors.js +22 -0
- package/lib/utils/createCertificate.js +14 -17
- package/lib/utils/createConfig.js +204 -0
- package/lib/utils/createDomain.js +7 -13
- package/lib/utils/createLogger.js +2 -5
- package/lib/utils/defaultTo.js +7 -0
- package/lib/utils/getVersions.js +12 -0
- package/lib/utils/runBonjour.js +21 -0
- package/lib/utils/status.js +62 -0
- package/package.json +44 -25
- package/bin/utils.js +0 -114
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
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.1](https://github.com/webpack/webpack-dev-server/compare/v3.2.0...v3.2.1) (2019-02-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
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))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<a name="3.1.14"></a>
|
|
18
|
+
## [3.1.14](https://github.com/webpack/webpack-dev-server/compare/v3.1.13...v3.1.14) (2018-12-24)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* add workaround for Origin header in sockjs ([#1608](https://github.com/webpack/webpack-dev-server/issues/1608)) ([1dfd4fb](https://github.com/webpack/webpack-dev-server/commit/1dfd4fb))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<a name="3.1.13"></a>
|
|
28
|
+
## [3.1.13](https://github.com/webpack/webpack-dev-server/compare/v3.1.12...v3.1.13) (2018-12-22)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* delete a comma for Node.js <= v7.x ([#1609](https://github.com/webpack/webpack-dev-server/issues/1609)) ([0bab1c0](https://github.com/webpack/webpack-dev-server/commit/0bab1c0))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
5
37
|
<a name="3.1.12"></a>
|
|
6
38
|
## [3.1.12](https://github.com/webpack/webpack-dev-server/compare/v3.1.11...v3.1.12) (2018-12-22)
|
|
7
39
|
|
package/README.md
CHANGED
|
@@ -19,6 +19,17 @@ live reloading. This should be used for **development only**.
|
|
|
19
19
|
It uses [webpack-dev-middleware][middleware-url] under the hood, which provides
|
|
20
20
|
fast in-memory access to the webpack assets.
|
|
21
21
|
|
|
22
|
+
## Table of Contents
|
|
23
|
+
|
|
24
|
+
1. [Getting Started](#getting-started)
|
|
25
|
+
2. [Usage](#usage)
|
|
26
|
+
3. [Browser Support](#browser-support)
|
|
27
|
+
4. [Support](#support)
|
|
28
|
+
5. [Contributing](#contributing)
|
|
29
|
+
6. [Maintainers](#maintainers)
|
|
30
|
+
7. [Attribution](#attribution)
|
|
31
|
+
8. [License](#license)
|
|
32
|
+
|
|
22
33
|
## Getting Started
|
|
23
34
|
|
|
24
35
|
First things first, install the module:
|
|
@@ -44,6 +55,8 @@ The easiest way to use it is with the CLI. In the directory where your
|
|
|
44
55
|
node_modules/.bin/webpack-dev-server
|
|
45
56
|
```
|
|
46
57
|
|
|
58
|
+
_**Note**: Many CLI options are available with `webpack-dev-server`. Explore this [link](https://webpack.js.org/configuration/dev-server/)._
|
|
59
|
+
|
|
47
60
|
### With NPM Scripts
|
|
48
61
|
|
|
49
62
|
NPM package.json scripts are a convenient and useful means to run locally installed
|
|
@@ -142,25 +155,18 @@ This project is heavily inspired by [peerigon/nof5](https://github.com/peerigon/
|
|
|
142
155
|
|
|
143
156
|
#### [MIT](./LICENSE)
|
|
144
157
|
|
|
145
|
-
|
|
146
158
|
[npm]: https://img.shields.io/npm/v/webpack-dev-server.svg
|
|
147
159
|
[npm-url]: https://npmjs.com/package/webpack-dev-server
|
|
148
|
-
|
|
149
160
|
[node]: https://img.shields.io/node/v/webpack-dev-server.svg
|
|
150
161
|
[node-url]: https://nodejs.org
|
|
151
|
-
|
|
152
162
|
[deps]: https://david-dm.org/webpack/webpack-dev-server.svg
|
|
153
163
|
[deps-url]: https://david-dm.org/webpack/webpack-dev-server
|
|
154
|
-
|
|
155
164
|
[tests]: http://img.shields.io/travis/webpack/webpack-dev-server.svg
|
|
156
165
|
[tests-url]: https://travis-ci.org/webpack/webpack-dev-server
|
|
157
|
-
|
|
158
166
|
[cover]: https://codecov.io/gh/webpack/webpack-dev-server/branch/master/graph/badge.svg
|
|
159
167
|
[cover-url]: https://codecov.io/gh/webpack/webpack-dev-server
|
|
160
|
-
|
|
161
168
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
162
169
|
[chat-url]: https://gitter.im/webpack/webpack
|
|
163
|
-
|
|
164
170
|
[docs-url]: https://webpack.js.org/configuration/dev-server/#devserver
|
|
165
171
|
[hash-url]: https://twitter.com/search?q=webpack
|
|
166
172
|
[middleware-url]: https://github.com/webpack/webpack-dev-middleware
|
package/bin/options.js
CHANGED
|
@@ -15,43 +15,44 @@ const BASIC_GROUP = 'Basic options:';
|
|
|
15
15
|
const options = {
|
|
16
16
|
bonjour: {
|
|
17
17
|
type: 'boolean',
|
|
18
|
-
describe: 'Broadcasts the server via ZeroConf networking on start'
|
|
18
|
+
describe: 'Broadcasts the server via ZeroConf networking on start',
|
|
19
19
|
},
|
|
20
20
|
lazy: {
|
|
21
21
|
type: 'boolean',
|
|
22
|
-
describe: 'Lazy'
|
|
22
|
+
describe: 'Lazy',
|
|
23
23
|
},
|
|
24
24
|
inline: {
|
|
25
25
|
type: 'boolean',
|
|
26
26
|
default: true,
|
|
27
|
-
describe:
|
|
27
|
+
describe:
|
|
28
|
+
'Inline mode (set to false to disable including client scripts like livereload)',
|
|
28
29
|
},
|
|
29
30
|
progress: {
|
|
30
31
|
type: 'boolean',
|
|
31
32
|
describe: 'Print compilation progress in percentage',
|
|
32
|
-
group: BASIC_GROUP
|
|
33
|
+
group: BASIC_GROUP,
|
|
33
34
|
},
|
|
34
35
|
'hot-only': {
|
|
35
36
|
type: 'boolean',
|
|
36
37
|
describe: 'Do not refresh page if HMR fails',
|
|
37
|
-
group: ADVANCED_GROUP
|
|
38
|
+
group: ADVANCED_GROUP,
|
|
38
39
|
},
|
|
39
40
|
stdin: {
|
|
40
41
|
type: 'boolean',
|
|
41
|
-
describe: 'close when stdin ends'
|
|
42
|
+
describe: 'close when stdin ends',
|
|
42
43
|
},
|
|
43
44
|
open: {
|
|
44
45
|
type: 'string',
|
|
45
|
-
describe: 'Open the default browser, or optionally specify a browser name'
|
|
46
|
+
describe: 'Open the default browser, or optionally specify a browser name',
|
|
46
47
|
},
|
|
47
48
|
useLocalIp: {
|
|
48
49
|
type: 'boolean',
|
|
49
|
-
describe: 'Open default browser with local IP'
|
|
50
|
+
describe: 'Open default browser with local IP',
|
|
50
51
|
},
|
|
51
52
|
'open-page': {
|
|
52
53
|
type: 'string',
|
|
53
54
|
describe: 'Open default browser with the specified page',
|
|
54
|
-
requiresArg: true
|
|
55
|
+
requiresArg: true,
|
|
55
56
|
},
|
|
56
57
|
color: {
|
|
57
58
|
type: 'boolean',
|
|
@@ -62,105 +63,106 @@ const options = {
|
|
|
62
63
|
return require('supports-color').stdout;
|
|
63
64
|
},
|
|
64
65
|
group: DISPLAY_GROUP,
|
|
65
|
-
describe: 'Enables/Disables colors on the console'
|
|
66
|
+
describe: 'Enables/Disables colors on the console',
|
|
66
67
|
},
|
|
67
68
|
info: {
|
|
68
69
|
type: 'boolean',
|
|
69
70
|
group: DISPLAY_GROUP,
|
|
70
71
|
default: true,
|
|
71
|
-
describe: 'Info'
|
|
72
|
+
describe: 'Info',
|
|
72
73
|
},
|
|
73
74
|
quiet: {
|
|
74
75
|
type: 'boolean',
|
|
75
76
|
group: DISPLAY_GROUP,
|
|
76
|
-
describe: 'Quiet'
|
|
77
|
+
describe: 'Quiet',
|
|
77
78
|
},
|
|
78
79
|
'client-log-level': {
|
|
79
80
|
type: 'string',
|
|
80
81
|
group: DISPLAY_GROUP,
|
|
81
82
|
default: 'info',
|
|
82
|
-
describe: 'Log level in the browser (info, warning, error or none)'
|
|
83
|
+
describe: 'Log level in the browser (info, warning, error or none)',
|
|
83
84
|
},
|
|
84
85
|
https: {
|
|
85
86
|
type: 'boolean',
|
|
86
87
|
group: SSL_GROUP,
|
|
87
|
-
describe: 'HTTPS'
|
|
88
|
+
describe: 'HTTPS',
|
|
88
89
|
},
|
|
89
90
|
key: {
|
|
90
91
|
type: 'string',
|
|
91
92
|
describe: 'Path to a SSL key.',
|
|
92
|
-
group: SSL_GROUP
|
|
93
|
+
group: SSL_GROUP,
|
|
93
94
|
},
|
|
94
95
|
cert: {
|
|
95
96
|
type: 'string',
|
|
96
97
|
describe: 'Path to a SSL certificate.',
|
|
97
|
-
group: SSL_GROUP
|
|
98
|
+
group: SSL_GROUP,
|
|
98
99
|
},
|
|
99
100
|
cacert: {
|
|
100
101
|
type: 'string',
|
|
101
102
|
describe: 'Path to a SSL CA certificate.',
|
|
102
|
-
group: SSL_GROUP
|
|
103
|
+
group: SSL_GROUP,
|
|
103
104
|
},
|
|
104
105
|
pfx: {
|
|
105
106
|
type: 'string',
|
|
106
107
|
describe: 'Path to a SSL pfx file.',
|
|
107
|
-
group: SSL_GROUP
|
|
108
|
+
group: SSL_GROUP,
|
|
108
109
|
},
|
|
109
110
|
'pfx-passphrase': {
|
|
110
111
|
type: 'string',
|
|
111
112
|
describe: 'Passphrase for pfx file.',
|
|
112
|
-
group: SSL_GROUP
|
|
113
|
+
group: SSL_GROUP,
|
|
113
114
|
},
|
|
114
115
|
'content-base': {
|
|
115
116
|
type: 'string',
|
|
116
117
|
describe: 'A directory or URL to serve HTML content from.',
|
|
117
|
-
group: RESPONSE_GROUP
|
|
118
|
+
group: RESPONSE_GROUP,
|
|
118
119
|
},
|
|
119
120
|
'watch-content-base': {
|
|
120
121
|
type: 'boolean',
|
|
121
122
|
describe: 'Enable live-reloading of the content-base.',
|
|
122
|
-
group: RESPONSE_GROUP
|
|
123
|
+
group: RESPONSE_GROUP,
|
|
123
124
|
},
|
|
124
125
|
'history-api-fallback': {
|
|
125
126
|
type: 'boolean',
|
|
126
127
|
describe: 'Fallback to /index.html for Single Page Applications.',
|
|
127
|
-
group: RESPONSE_GROUP
|
|
128
|
+
group: RESPONSE_GROUP,
|
|
128
129
|
},
|
|
129
130
|
compress: {
|
|
130
131
|
type: 'boolean',
|
|
131
132
|
describe: 'Enable gzip compression',
|
|
132
|
-
group: RESPONSE_GROUP
|
|
133
|
+
group: RESPONSE_GROUP,
|
|
133
134
|
},
|
|
134
135
|
port: {
|
|
135
136
|
describe: 'The port',
|
|
136
|
-
group: CONNECTION_GROUP
|
|
137
|
+
group: CONNECTION_GROUP,
|
|
137
138
|
},
|
|
138
139
|
'disable-host-check': {
|
|
139
140
|
type: 'boolean',
|
|
140
141
|
describe: 'Will not check the host',
|
|
141
|
-
group: CONNECTION_GROUP
|
|
142
|
+
group: CONNECTION_GROUP,
|
|
142
143
|
},
|
|
143
144
|
socket: {
|
|
144
145
|
type: 'String',
|
|
145
146
|
describe: 'Socket to listen',
|
|
146
|
-
group: CONNECTION_GROUP
|
|
147
|
+
group: CONNECTION_GROUP,
|
|
147
148
|
},
|
|
148
149
|
public: {
|
|
149
150
|
type: 'string',
|
|
150
151
|
describe: 'The public hostname/ip address of the server',
|
|
151
|
-
group: CONNECTION_GROUP
|
|
152
|
+
group: CONNECTION_GROUP,
|
|
152
153
|
},
|
|
153
154
|
host: {
|
|
154
155
|
type: 'string',
|
|
155
156
|
default: 'localhost',
|
|
156
157
|
describe: 'The hostname/ip address the server will bind to',
|
|
157
|
-
group: CONNECTION_GROUP
|
|
158
|
+
group: CONNECTION_GROUP,
|
|
158
159
|
},
|
|
159
160
|
'allowed-hosts': {
|
|
160
161
|
type: 'string',
|
|
161
|
-
describe:
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
describe:
|
|
163
|
+
'A comma-delimited string of hosts that are allowed to access the dev server',
|
|
164
|
+
group: CONNECTION_GROUP,
|
|
165
|
+
},
|
|
164
166
|
};
|
|
165
167
|
|
|
166
168
|
module.exports = options;
|
|
@@ -4,20 +4,13 @@
|
|
|
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
|
|
|
18
12
|
const fs = require('fs');
|
|
19
13
|
const net = require('net');
|
|
20
|
-
const path = require('path');
|
|
21
14
|
|
|
22
15
|
const portfinder = require('portfinder');
|
|
23
16
|
const importLocal = require('import-local');
|
|
@@ -27,23 +20,20 @@ const webpack = require('webpack');
|
|
|
27
20
|
|
|
28
21
|
const options = require('./options');
|
|
29
22
|
|
|
30
|
-
const {
|
|
31
|
-
colors,
|
|
32
|
-
status,
|
|
33
|
-
version,
|
|
34
|
-
bonjour,
|
|
35
|
-
defaultTo
|
|
36
|
-
} = require('./utils');
|
|
37
|
-
|
|
38
23
|
const Server = require('../lib/Server');
|
|
39
24
|
|
|
40
25
|
const addEntries = require('../lib/utils/addEntries');
|
|
26
|
+
const colors = require('../lib/utils/colors');
|
|
27
|
+
const createConfig = require('../lib/utils/createConfig');
|
|
41
28
|
const createDomain = require('../lib/utils/createDomain');
|
|
42
29
|
const createLogger = require('../lib/utils/createLogger');
|
|
30
|
+
const getVersions = require('../lib/utils/getVersions');
|
|
31
|
+
const runBonjour = require('../lib/utils/runBonjour');
|
|
32
|
+
const status = require('../lib/utils/status');
|
|
43
33
|
|
|
44
34
|
let server;
|
|
45
35
|
|
|
46
|
-
const signals = [
|
|
36
|
+
const signals = ['SIGINT', 'SIGTERM'];
|
|
47
37
|
|
|
48
38
|
signals.forEach((signal) => {
|
|
49
39
|
process.on(signal, () => {
|
|
@@ -70,7 +60,9 @@ try {
|
|
|
70
60
|
require.resolve('webpack-cli');
|
|
71
61
|
} catch (err) {
|
|
72
62
|
console.error('The CLI moved into a separate package: webpack-cli');
|
|
73
|
-
console.error(
|
|
63
|
+
console.error(
|
|
64
|
+
"Please install 'webpack-cli' in addition to webpack itself to use the CLI"
|
|
65
|
+
);
|
|
74
66
|
console.error('-> When using npm: npm i -D webpack-cli');
|
|
75
67
|
console.error('-> When using yarn: yarn add -D webpack-cli');
|
|
76
68
|
|
|
@@ -78,26 +70,30 @@ try {
|
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
yargs.usage(
|
|
81
|
-
`${
|
|
73
|
+
`${getVersions()}\nUsage: https://webpack.js.org/configuration/dev-server/`
|
|
82
74
|
);
|
|
83
75
|
|
|
76
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
84
77
|
require('webpack-cli/bin/config-yargs')(yargs);
|
|
78
|
+
|
|
85
79
|
// It is important that this is done after the webpack yargs config,
|
|
86
80
|
// so it overrides webpack's version info.
|
|
87
|
-
yargs.version(
|
|
81
|
+
yargs.version(getVersions());
|
|
88
82
|
yargs.options(options);
|
|
89
83
|
|
|
90
84
|
const argv = yargs.argv;
|
|
91
85
|
|
|
86
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
92
87
|
const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
|
|
93
|
-
outputFilename: '/bundle.js'
|
|
88
|
+
outputFilename: '/bundle.js',
|
|
94
89
|
});
|
|
90
|
+
|
|
95
91
|
// Taken out of yargs because we must know if
|
|
96
92
|
// it wasn't given by the user, in which case
|
|
97
93
|
// we should use portfinder.
|
|
98
94
|
const DEFAULT_PORT = 8080;
|
|
99
95
|
|
|
100
|
-
function processOptions
|
|
96
|
+
function processOptions(config) {
|
|
101
97
|
// processOptions {Promise}
|
|
102
98
|
if (typeof config.then === 'function') {
|
|
103
99
|
config.then(processOptions).catch((err) => {
|
|
@@ -109,201 +105,9 @@ function processOptions (config) {
|
|
|
109
105
|
return;
|
|
110
106
|
}
|
|
111
107
|
|
|
112
|
-
const
|
|
113
|
-
? config[0]
|
|
114
|
-
: config;
|
|
115
|
-
|
|
116
|
-
const options = config.devServer || firstWpOpt.devServer || {};
|
|
117
|
-
|
|
118
|
-
if (argv.bonjour) {
|
|
119
|
-
options.bonjour = true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (argv.host !== 'localhost' || !options.host) {
|
|
123
|
-
options.host = argv.host;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (argv['allowed-hosts']) {
|
|
127
|
-
options.allowedHosts = argv['allowed-hosts'].split(',');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (argv.public) {
|
|
131
|
-
options.public = argv.public;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (argv.socket) {
|
|
135
|
-
options.socket = argv.socket;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (argv.progress) {
|
|
139
|
-
options.progress = argv.progress;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!options.publicPath) {
|
|
143
|
-
// eslint-disable-next-line
|
|
144
|
-
options.publicPath = firstWpOpt.output && firstWpOpt.output.publicPath || '';
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
!/^(https?:)?\/\//.test(options.publicPath) &&
|
|
148
|
-
options.publicPath[0] !== '/'
|
|
149
|
-
) {
|
|
150
|
-
options.publicPath = `/${options.publicPath}`;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (!options.filename) {
|
|
155
|
-
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!options.watchOptions) {
|
|
159
|
-
options.watchOptions = firstWpOpt.watchOptions;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (argv.stdin) {
|
|
163
|
-
process.stdin.on('end', () => {
|
|
164
|
-
// eslint-disable-next-line no-process-exit
|
|
165
|
-
process.exit(0);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
process.stdin.resume();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (!options.hot) {
|
|
172
|
-
options.hot = argv.hot;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (!options.hotOnly) {
|
|
176
|
-
options.hotOnly = argv['hot-only'];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!options.clientLogLevel) {
|
|
180
|
-
options.clientLogLevel = argv['client-log-level'];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// eslint-disable-next-line
|
|
184
|
-
if (options.contentBase === undefined) {
|
|
185
|
-
if (argv['content-base']) {
|
|
186
|
-
options.contentBase = argv['content-base'];
|
|
187
|
-
|
|
188
|
-
if (Array.isArray(options.contentBase)) {
|
|
189
|
-
options.contentBase = options.contentBase.map((p) => path.resolve(p));
|
|
190
|
-
} else if (/^[0-9]$/.test(options.contentBase)) {
|
|
191
|
-
options.contentBase = +options.contentBase;
|
|
192
|
-
} else if (!/^(https?:)?\/\//.test(options.contentBase)) {
|
|
193
|
-
options.contentBase = path.resolve(options.contentBase);
|
|
194
|
-
}
|
|
195
|
-
// It is possible to disable the contentBase by using
|
|
196
|
-
// `--no-content-base`, which results in arg["content-base"] = false
|
|
197
|
-
} else if (argv['content-base'] === false) {
|
|
198
|
-
options.contentBase = false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (argv['watch-content-base']) {
|
|
203
|
-
options.watchContentBase = true;
|
|
204
|
-
}
|
|
108
|
+
const options = createConfig(config, argv, { port: DEFAULT_PORT });
|
|
205
109
|
|
|
206
|
-
|
|
207
|
-
options.stats = {
|
|
208
|
-
cached: false,
|
|
209
|
-
cachedAssets: false
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (
|
|
214
|
-
typeof options.stats === 'object' &&
|
|
215
|
-
typeof options.stats.colors === 'undefined'
|
|
216
|
-
) {
|
|
217
|
-
options.stats = Object.assign(
|
|
218
|
-
{},
|
|
219
|
-
options.stats,
|
|
220
|
-
{ colors: argv.color }
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (argv.lazy) {
|
|
225
|
-
options.lazy = true;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!argv.info) {
|
|
229
|
-
options.noInfo = true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (argv.quiet) {
|
|
233
|
-
options.quiet = true;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (argv.https) {
|
|
237
|
-
options.https = true;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (argv.cert) {
|
|
241
|
-
options.cert = fs.readFileSync(
|
|
242
|
-
path.resolve(argv.cert)
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (argv.key) {
|
|
247
|
-
options.key = fs.readFileSync(
|
|
248
|
-
path.resolve(argv.key)
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (argv.cacert) {
|
|
253
|
-
options.ca = fs.readFileSync(
|
|
254
|
-
path.resolve(argv.cacert)
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (argv.pfx) {
|
|
259
|
-
options.pfx = fs.readFileSync(
|
|
260
|
-
path.resolve(argv.pfx)
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (argv['pfx-passphrase']) {
|
|
265
|
-
options.pfxPassphrase = argv['pfx-passphrase'];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (argv.inline === false) {
|
|
269
|
-
options.inline = false;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (argv['history-api-fallback']) {
|
|
273
|
-
options.historyApiFallback = true;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (argv.compress) {
|
|
277
|
-
options.compress = true;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (argv['disable-host-check']) {
|
|
281
|
-
options.disableHostCheck = true;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (argv['open-page']) {
|
|
285
|
-
options.open = true;
|
|
286
|
-
options.openPage = argv['open-page'];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (typeof argv.open !== 'undefined') {
|
|
290
|
-
options.open = argv.open !== '' ? argv.open : true;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (options.open && !options.openPage) {
|
|
294
|
-
options.openPage = '';
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (argv.useLocalIp) {
|
|
298
|
-
options.useLocalIp = true;
|
|
299
|
-
}
|
|
300
|
-
// Kind of weird, but ensures prior behavior isn't broken in cases
|
|
301
|
-
// that wouldn't throw errors. E.g. both argv.port and options.port
|
|
302
|
-
// were specified, but since argv.port is 8080, options.port will be
|
|
303
|
-
// tried first instead.
|
|
304
|
-
options.port = argv.port === DEFAULT_PORT
|
|
305
|
-
? defaultTo(options.port, argv.port)
|
|
306
|
-
: defaultTo(argv.port, options.port);
|
|
110
|
+
portfinder.basePort = DEFAULT_PORT;
|
|
307
111
|
|
|
308
112
|
if (options.port != null) {
|
|
309
113
|
startDevServer(config, options);
|
|
@@ -311,8 +115,6 @@ function processOptions (config) {
|
|
|
311
115
|
return;
|
|
312
116
|
}
|
|
313
117
|
|
|
314
|
-
portfinder.basePort = DEFAULT_PORT;
|
|
315
|
-
|
|
316
118
|
portfinder.getPort((err, port) => {
|
|
317
119
|
if (err) {
|
|
318
120
|
throw err;
|
|
@@ -345,11 +147,14 @@ function startDevServer(config, options) {
|
|
|
345
147
|
|
|
346
148
|
if (options.progress) {
|
|
347
149
|
new webpack.ProgressPlugin({
|
|
348
|
-
profile: argv.profile
|
|
150
|
+
profile: argv.profile,
|
|
349
151
|
}).apply(compiler);
|
|
350
152
|
}
|
|
351
153
|
|
|
352
|
-
const suffix =
|
|
154
|
+
const suffix =
|
|
155
|
+
options.inline !== false || options.lazy === true
|
|
156
|
+
? '/'
|
|
157
|
+
: '/webpack-dev-server/';
|
|
353
158
|
|
|
354
159
|
try {
|
|
355
160
|
server = new Server(compiler, options, log);
|
|
@@ -411,7 +216,7 @@ function startDevServer(config, options) {
|
|
|
411
216
|
}
|
|
412
217
|
|
|
413
218
|
if (options.bonjour) {
|
|
414
|
-
|
|
219
|
+
runBonjour(options);
|
|
415
220
|
}
|
|
416
221
|
|
|
417
222
|
const uri = createDomain(options, server.listeningApp) + suffix;
|