webpack-dev-server 3.1.14 → 3.3.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 +45 -0
- package/README.md +14 -27
- package/bin/options.js +43 -31
- package/bin/webpack-dev-server.js +76 -249
- package/client/index.bundle.js +1 -1
- package/client/index.js +92 -42
- 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 +798 -683
- package/lib/options.json +40 -35
- package/lib/utils/addEntries.js +32 -11
- package/lib/utils/colors.js +22 -0
- package/lib/utils/createCertificate.js +14 -17
- package/lib/utils/createConfig.js +208 -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/findPort.js +35 -0
- package/lib/utils/getVersions.js +12 -0
- package/lib/utils/runBonjour.js +21 -0
- package/lib/utils/status.js +62 -0
- package/lib/utils/tryParseInt.js +11 -0
- package/lib/utils/updateCompiler.js +67 -0
- package/package.json +72 -52
- package/bin/utils.js +0 -114
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const open = require('opn');
|
|
4
|
+
const colors = require('./colors');
|
|
5
|
+
|
|
6
|
+
function status(uri, options, log, useColor) {
|
|
7
|
+
const contentBase = Array.isArray(options.contentBase)
|
|
8
|
+
? options.contentBase.join(', ')
|
|
9
|
+
: options.contentBase;
|
|
10
|
+
|
|
11
|
+
if (options.socket) {
|
|
12
|
+
log.info(`Listening to socket at ${colors.info(useColor, options.socket)}`);
|
|
13
|
+
} else {
|
|
14
|
+
log.info(`Project is running at ${colors.info(useColor, uri)}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
log.info(
|
|
18
|
+
`webpack output is served from ${colors.info(useColor, options.publicPath)}`
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (contentBase) {
|
|
22
|
+
log.info(
|
|
23
|
+
`Content not from webpack is served from ${colors.info(
|
|
24
|
+
useColor,
|
|
25
|
+
contentBase
|
|
26
|
+
)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (options.historyApiFallback) {
|
|
31
|
+
log.info(
|
|
32
|
+
`404s will fallback to ${colors.info(
|
|
33
|
+
useColor,
|
|
34
|
+
options.historyApiFallback.index || '/index.html'
|
|
35
|
+
)}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (options.bonjour) {
|
|
40
|
+
log.info(
|
|
41
|
+
'Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.open) {
|
|
46
|
+
let openOptions = {};
|
|
47
|
+
let openMessage = 'Unable to open browser';
|
|
48
|
+
|
|
49
|
+
if (typeof options.open === 'string') {
|
|
50
|
+
openOptions = { app: options.open };
|
|
51
|
+
openMessage += `: ${options.open}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
open(uri + (options.openPage || ''), openOptions).catch(() => {
|
|
55
|
+
log.warn(
|
|
56
|
+
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = status;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable
|
|
4
|
+
no-shadow,
|
|
5
|
+
no-undefined
|
|
6
|
+
*/
|
|
7
|
+
const webpack = require('webpack');
|
|
8
|
+
const addEntries = require('./addEntries');
|
|
9
|
+
|
|
10
|
+
function updateCompiler(compiler, options) {
|
|
11
|
+
if (options.inline !== false) {
|
|
12
|
+
const findHMRPlugin = (config) => {
|
|
13
|
+
if (!config.plugins) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return config.plugins.find(
|
|
18
|
+
(plugin) => plugin.constructor === webpack.HotModuleReplacementPlugin
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const compilers = [];
|
|
23
|
+
const compilersWithoutHMR = [];
|
|
24
|
+
let webpackConfig;
|
|
25
|
+
if (compiler.compilers) {
|
|
26
|
+
webpackConfig = [];
|
|
27
|
+
compiler.compilers.forEach((compiler) => {
|
|
28
|
+
webpackConfig.push(compiler.options);
|
|
29
|
+
compilers.push(compiler);
|
|
30
|
+
if (!findHMRPlugin(compiler.options)) {
|
|
31
|
+
compilersWithoutHMR.push(compiler);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
webpackConfig = compiler.options;
|
|
36
|
+
compilers.push(compiler);
|
|
37
|
+
if (!findHMRPlugin(compiler.options)) {
|
|
38
|
+
compilersWithoutHMR.push(compiler);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// it's possible that we should clone the config before doing
|
|
43
|
+
// this, but it seems safe not to since it actually reflects
|
|
44
|
+
// the changes we are making to the compiler
|
|
45
|
+
// important: this relies on the fact that addEntries now
|
|
46
|
+
// prevents duplicate new entries.
|
|
47
|
+
addEntries(webpackConfig, options);
|
|
48
|
+
compilers.forEach((compiler) => {
|
|
49
|
+
const config = compiler.options;
|
|
50
|
+
compiler.hooks.entryOption.call(config.context, config.entry);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// do not apply the plugin unless it didn't exist before.
|
|
54
|
+
if (options.hot || options.hotOnly) {
|
|
55
|
+
compilersWithoutHMR.forEach((compiler) => {
|
|
56
|
+
// addDevServerEntrypoints above should have added the plugin
|
|
57
|
+
// to the compiler options
|
|
58
|
+
const plugin = findHMRPlugin(compiler.options);
|
|
59
|
+
if (plugin) {
|
|
60
|
+
plugin.apply(compiler);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = updateCompiler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint bin lib test examples client-src",
|
|
18
|
-
"
|
|
18
|
+
"pretty": "prettier --loglevel warn --write \"**/*.{js,css,md,json,yml}\"",
|
|
19
|
+
"test": "jest --runInBand",
|
|
19
20
|
"prepare": "rimraf ./ssl/*.pem && npm run -s transpile:index && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs",
|
|
20
21
|
"transpile:index": "babel client-src/default --out-dir client --ignore *.config.js",
|
|
21
22
|
"build:index": "webpack ./client-src/default/index.js -o client/index.bundle.js --color --config client-src/default/webpack.config.js",
|
|
@@ -27,70 +28,89 @@
|
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"ansi-html": "0.0.7",
|
|
29
30
|
"bonjour": "^3.5.0",
|
|
30
|
-
"chokidar": "^2.
|
|
31
|
-
"compression": "^1.
|
|
32
|
-
"connect-history-api-fallback": "^1.
|
|
33
|
-
"debug": "^
|
|
34
|
-
"del": "^
|
|
35
|
-
"express": "^4.16.
|
|
36
|
-
"html-entities": "^1.2.
|
|
37
|
-
"http-proxy-middleware": "
|
|
31
|
+
"chokidar": "^2.1.5",
|
|
32
|
+
"compression": "^1.7.4",
|
|
33
|
+
"connect-history-api-fallback": "^1.6.0",
|
|
34
|
+
"debug": "^4.1.1",
|
|
35
|
+
"del": "^4.1.0",
|
|
36
|
+
"express": "^4.16.4",
|
|
37
|
+
"html-entities": "^1.2.1",
|
|
38
|
+
"http-proxy-middleware": "^0.19.1",
|
|
38
39
|
"import-local": "^2.0.0",
|
|
39
|
-
"internal-ip": "^
|
|
40
|
+
"internal-ip": "^4.2.0",
|
|
40
41
|
"ip": "^1.1.5",
|
|
41
|
-
"killable": "^1.0.
|
|
42
|
-
"loglevel": "^1.
|
|
43
|
-
"opn": "^5.
|
|
44
|
-
"portfinder": "^1.0.
|
|
42
|
+
"killable": "^1.0.1",
|
|
43
|
+
"loglevel": "^1.6.1",
|
|
44
|
+
"opn": "^5.5.0",
|
|
45
|
+
"portfinder": "^1.0.20",
|
|
45
46
|
"schema-utils": "^1.0.0",
|
|
46
|
-
"selfsigned": "^1.
|
|
47
|
-
"semver": "^
|
|
48
|
-
"serve-index": "^1.
|
|
47
|
+
"selfsigned": "^1.10.4",
|
|
48
|
+
"semver": "^6.0.0",
|
|
49
|
+
"serve-index": "^1.9.1",
|
|
49
50
|
"sockjs": "0.3.19",
|
|
50
51
|
"sockjs-client": "1.3.0",
|
|
51
52
|
"spdy": "^4.0.0",
|
|
52
|
-
"strip-ansi": "^3.0.
|
|
53
|
-
"supports-color": "^
|
|
53
|
+
"strip-ansi": "^3.0.1",
|
|
54
|
+
"supports-color": "^6.1.0",
|
|
54
55
|
"url": "^0.11.0",
|
|
55
|
-
"webpack-dev-middleware": "3.
|
|
56
|
+
"webpack-dev-middleware": "^3.6.2",
|
|
56
57
|
"webpack-log": "^2.0.0",
|
|
57
|
-
"yargs": "12.0.
|
|
58
|
+
"yargs": "12.0.5"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"babel
|
|
61
|
-
"babel
|
|
62
|
-
"babel-
|
|
63
|
-
"babel-
|
|
64
|
-
"copy-webpack-plugin": "
|
|
65
|
-
"css-loader": "
|
|
66
|
-
"eslint": "
|
|
67
|
-
"eslint-config-
|
|
68
|
-
"eslint-
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
61
|
+
"@babel/cli": "7.4.3",
|
|
62
|
+
"@babel/core": "7.4.3",
|
|
63
|
+
"@babel/preset-env": "7.4.3",
|
|
64
|
+
"babel-loader": "8.0.5",
|
|
65
|
+
"copy-webpack-plugin": "5.0.2",
|
|
66
|
+
"css-loader": "2.1.1",
|
|
67
|
+
"eslint": "5.16.0",
|
|
68
|
+
"eslint-config-prettier": "4.1.0",
|
|
69
|
+
"eslint-config-webpack": "1.2.5",
|
|
70
|
+
"eslint-plugin-import": "2.16.0",
|
|
71
|
+
"eslint-plugin-prettier": "3.0.1",
|
|
72
|
+
"execa": "1.0.0",
|
|
73
|
+
"file-loader": "3.0.1",
|
|
74
|
+
"html-loader": "0.5.5",
|
|
75
|
+
"html-webpack-plugin": "3.2.0",
|
|
76
|
+
"husky": "1.3.1",
|
|
77
|
+
"jest": "24.7.1",
|
|
78
|
+
"jquery": "3.3.1",
|
|
79
|
+
"less": "3.9.0",
|
|
80
|
+
"less-loader": "4.1.0",
|
|
81
|
+
"lint-staged": "8.1.5",
|
|
82
|
+
"marked": "0.6.2",
|
|
83
|
+
"nyc": "13.3.0",
|
|
84
|
+
"prettier": "1.16.4",
|
|
85
|
+
"puppeteer": "1.14.0",
|
|
86
|
+
"rimraf": "2.6.3",
|
|
87
|
+
"standard-version": "5.0.2",
|
|
88
|
+
"style-loader": "0.23.1",
|
|
89
|
+
"supertest": "4.0.2",
|
|
90
|
+
"url-loader": "1.1.2",
|
|
91
|
+
"webpack": "4.29.6",
|
|
92
|
+
"webpack-cli": "3.3.0",
|
|
93
|
+
"ws": "6.2.1"
|
|
90
94
|
},
|
|
91
95
|
"peerDependencies": {
|
|
92
96
|
"webpack": "^4.0.0"
|
|
93
97
|
},
|
|
98
|
+
"husky": {
|
|
99
|
+
"hooks": {
|
|
100
|
+
"pre-commit": "lint-staged"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"lint-staged": {
|
|
104
|
+
"*.js": [
|
|
105
|
+
"eslint --fix",
|
|
106
|
+
"prettier --write",
|
|
107
|
+
"git add"
|
|
108
|
+
],
|
|
109
|
+
"*.{css,md,json,yml}": [
|
|
110
|
+
"prettier --write",
|
|
111
|
+
"git add"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
94
114
|
"author": "Tobias Koppers @sokra",
|
|
95
115
|
"bugs": "https://github.com/webpack/webpack-dev-server/issues",
|
|
96
116
|
"homepage": "https://github.com/webpack/webpack-dev-server#readme",
|
package/bin/utils.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable
|
|
4
|
-
no-shadow,
|
|
5
|
-
global-require,
|
|
6
|
-
multiline-ternary,
|
|
7
|
-
array-bracket-spacing,
|
|
8
|
-
space-before-function-paren
|
|
9
|
-
*/
|
|
10
|
-
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 `webpack-dev-server ${require('../package.json').version}\n` +
|
|
38
|
-
`webpack ${require('webpack/package.json').version}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function status (uri, options, log, useColor) {
|
|
42
|
-
const contentBase = Array.isArray(options.contentBase)
|
|
43
|
-
? options.contentBase.join(', ')
|
|
44
|
-
: options.contentBase;
|
|
45
|
-
|
|
46
|
-
if (options.socket) {
|
|
47
|
-
log.info(`Listening to socket at ${colors.info(useColor, options.socket)}`);
|
|
48
|
-
} else {
|
|
49
|
-
log.info(`Project is running at ${colors.info(useColor, uri)}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
log.info(
|
|
53
|
-
`webpack output is served from ${colors.info(useColor, options.publicPath)}`
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
if (contentBase) {
|
|
57
|
-
log.info(
|
|
58
|
-
`Content not from webpack is served from ${colors.info(useColor, contentBase)}`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (options.historyApiFallback) {
|
|
63
|
-
log.info(
|
|
64
|
-
`404s will fallback to ${colors.info(useColor, options.historyApiFallback.index || '/index.html')}`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (options.bonjour) {
|
|
69
|
-
log.info(
|
|
70
|
-
'Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)'
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (options.open) {
|
|
75
|
-
let openOptions = {};
|
|
76
|
-
let openMessage = 'Unable to open browser';
|
|
77
|
-
|
|
78
|
-
if (typeof options.open === 'string') {
|
|
79
|
-
openOptions = { app: options.open };
|
|
80
|
-
openMessage += `: ${options.open}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
open(uri + (options.openPage || ''), openOptions).catch(() => {
|
|
84
|
-
log.warn(
|
|
85
|
-
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function bonjour (options) {
|
|
92
|
-
const bonjour = require('bonjour')();
|
|
93
|
-
|
|
94
|
-
bonjour.publish({
|
|
95
|
-
name: 'Webpack Dev Server',
|
|
96
|
-
port: options.port,
|
|
97
|
-
type: 'http',
|
|
98
|
-
subtypes: [ 'webpack' ]
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
process.on('exit', () => {
|
|
102
|
-
bonjour.unpublishAll(() => {
|
|
103
|
-
bonjour.destroy();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
module.exports = {
|
|
109
|
-
status,
|
|
110
|
-
colors,
|
|
111
|
-
version,
|
|
112
|
-
bonjour,
|
|
113
|
-
defaultTo
|
|
114
|
-
};
|