Skip to content

Commit 2e68d84

Browse files
committed
feat: show info message only if publicPath is function
1 parent 2323bf3 commit 2e68d84

14 files changed

+52
-145
lines changed

lib/Server.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3077,12 +3077,7 @@ class Server {
30773077
);
30783078
}
30793079

3080-
const publicPath = compilerOptions.output.publicPath;
3081-
3082-
const isOnTheFlyDefinedPublicPath =
3083-
typeof publicPath === "function" || publicPath === "auto";
3084-
3085-
if (isOnTheFlyDefinedPublicPath) {
3080+
if (typeof compilerOptions.output.publicPath === "function") {
30863081
this.logger.info(
30873082
`You probably have a custom public path, please navigate in your browser to the point that you required`,
30883083
);

test/cli/__snapshots__/basic.test.js.snap.webpack5

+4-16
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ exports[`basic basic should accept the promise function of webpack.config.js: st
55
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
66
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
77
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
9-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
109
`;
1110

1211
exports[`basic basic should respect output.publicPath config option in URL's output: stderr 1`] = `
@@ -16,14 +15,6 @@ exports[`basic basic should respect output.publicPath config option in URL's out
1615
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
1716
`;
1817

19-
exports[`basic basic should show info message when output.publicPath equals 'auto': stderr 1`] = `
20-
"<i> [webpack-dev-server] Project is running at:
21-
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
22-
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
23-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
24-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
25-
`;
26-
2718
exports[`basic basic should show info message when output.publicPath is function: stderr 1`] = `
2819
"<i> [webpack-dev-server] Project is running at:
2920
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
@@ -35,26 +26,23 @@ exports[`basic basic should show info message when output.publicPath is function
3526
exports[`basic basic should work using "--host localhost --port <port>": stderr 1`] = `
3627
"<i> [webpack-dev-server] Project is running at:
3728
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
38-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
39-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
29+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
4030
`;
4131

4232
exports[`basic basic should work using multi compiler mode: stderr 1`] = `
4333
"<i> [webpack-dev-server] Project is running at:
4434
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
4535
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
4636
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
47-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
48-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
37+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
4938
`;
5039

5140
exports[`basic basic should work: stderr 1`] = `
5241
"<i> [webpack-dev-server] Project is running at:
5342
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
5443
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
5544
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
56-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
57-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
45+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
5846
`;
5947

6048
exports[`basic should output help should generate correct cli flags 1`] = `

test/cli/__snapshots__/bonjour-option.test.js.snap.webpack5

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ exports[`"bonjour" CLI option should work using "--bonjour and --server-type=htt
88
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
99
<i> [webpack-dev-server] On Your Network (IPv6): https://[<ip-v6>]:<port>/
1010
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
11-
<i> [webpack-dev-server] Broadcasting "https" with subtype of "webpack" via ZeroConf DNS (Bonjour)
12-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
11+
<i> [webpack-dev-server] Broadcasting "https" with subtype of "webpack" via ZeroConf DNS (Bonjour)"
1312
`;
1413

1514
exports[`"bonjour" CLI option should work using "--bonjour" 1`] = `
@@ -18,15 +17,13 @@ exports[`"bonjour" CLI option should work using "--bonjour" 1`] = `
1817
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
1918
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
2019
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
21-
<i> [webpack-dev-server] Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)
22-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
20+
<i> [webpack-dev-server] Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)"
2321
`;
2422

2523
exports[`"bonjour" CLI option should work using "--no-bonjour" 1`] = `
2624
"<i> [webpack-dev-server] Project is running at:
2725
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
2826
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
2927
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
30-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
31-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
28+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
3229
`;

test/cli/__snapshots__/colors.test.js.snap.webpack5

+5-10
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,37 @@ exports[`colors should work and do not use colors using configuration with disab
55
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
66
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
77
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
9-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
109
`;
1110

1211
exports[`colors should work do not use colors using "--no-color": stderr 1`] = `
1312
"<i> [webpack-dev-server] Project is running at:
1413
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
1514
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
1615
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
17-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
18-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
16+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
1917
`;
2018

2119
exports[`colors should work use colors by default: stderr 1`] = `
2220
"<i> [webpack-dev-server] Project is running at:
2321
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
2422
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
2523
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
26-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
27-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
24+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
2825
`;
2926

3027
exports[`colors should work use colors using "--color": stderr 1`] = `
3128
"<i> [webpack-dev-server] Project is running at:
3229
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
3330
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
3431
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
35-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
36-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
32+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
3733
`;
3834

3935
exports[`colors should work use colors using configuration with enabled colors: stderr 1`] = `
4036
"<i> [webpack-dev-server] Project is running at:
4137
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
4238
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
4339
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
44-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
45-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
40+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
4641
`;

test/cli/__snapshots__/historyApiFallback-option.test.js.snap.webpack5

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ exports[`"historyApiFallback" CLI option should work using "--history-api-fallba
66
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
77
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
88
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
9-
<i> [webpack-dev-server] 404s will fallback to '/index.html'
10-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
9+
<i> [webpack-dev-server] 404s will fallback to '/index.html'"
1110
`;
1211

1312
exports[`"historyApiFallback" CLI option should work using "--no-history-api-fallback" 1`] = `

test/cli/__snapshots__/host-option.test.js.snap.webpack5

+9-18
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,55 @@ exports[`"host" CLI option should work using "--host ::" (IPv6): stderr 1`] = `
55
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
66
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
77
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
9-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
109
`;
1110

1211
exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 1`] = `
1312
"<i> [webpack-dev-server] Project is running at:
1413
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
15-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
16-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
14+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
1715
`;
1816

1917
exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 2`] = `
2018
"<i> [webpack-dev-server] Project is running at:
2119
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
22-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
23-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
20+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
2421
`;
2522

2623
exports[`"host" CLI option should work using "--host <IPv4>": stderr 1`] = `
2724
"<i> [webpack-dev-server] Project is running at:
2825
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
29-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
30-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
26+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
3127
`;
3228

3329
exports[`"host" CLI option should work using "--host 0.0.0.0" (IPv4): stderr 1`] = `
3430
"<i> [webpack-dev-server] Project is running at:
3531
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
3632
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
3733
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
38-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
39-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
34+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
4035
`;
4136

4237
exports[`"host" CLI option should work using "--host 127.0.0.1" (IPv4): stderr 1`] = `
4338
"<i> [webpack-dev-server] Project is running at:
4439
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
45-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
46-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
40+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
4741
`;
4842

4943
exports[`"host" CLI option should work using "--host local-ip": stderr 1`] = `
5044
"<i> [webpack-dev-server] Project is running at:
5145
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
52-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
53-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
46+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
5447
`;
5548

5649
exports[`"host" CLI option should work using "--host local-ipv4": stderr 1`] = `
5750
"<i> [webpack-dev-server] Project is running at:
5851
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
59-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
60-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
52+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
6153
`;
6254

6355
exports[`"host" CLI option should work using "--host localhost": stderr 1`] = `
6456
"<i> [webpack-dev-server] Project is running at:
6557
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
66-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
67-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
58+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
6859
`;

test/cli/__snapshots__/ipc-option.test.js.snap.webpack5

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
exports[`"ipc" CLI option should work using "--ipc": stderr 1`] = `
44
"<i> [webpack-dev-server] Project is running at: "<tmp>/webpack-dev-server.sock"
5-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
6-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
5+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
76
`;
87

98
exports[`"ipc" CLI option should work using "--ipc=<string>": stderr 1`] = `
109
"<i> [webpack-dev-server] Project is running at: "<tmp>/webpack-dev-server.cli.sock"
11-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
12-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
10+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
1311
`;

test/cli/__snapshots__/port-option.test.js.snap.webpack5

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ exports[`"port" CLI option should work using "--port <string>": stderr 1`] = `
55
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
66
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
77
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
9-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
109
`;
1110

1211
exports[`"port" CLI option should work using "--port auto": stderr 1`] = `
1312
"<i> [webpack-dev-server] Project is running at:
1413
<i> Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/, http://[<ip-v6>]:<port>/
1514
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
1615
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
17-
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory
18-
<i> [webpack-dev-server] You probably have a custom public path, please navigate in your browser to the point that you required"
16+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
1917
`;

0 commit comments

Comments
 (0)