Skip to content

Commit 5063ed7

Browse files
fix: avoid unnecessary searching port (#2648)
1 parent 295f5db commit 5063ed7

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

packages/serve/src/startDevServer.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ export default async function startDevServer(
2121
cliOptions: any,
2222
logger: any,
2323
): Promise<Record<string, unknown>[]> {
24-
let devServerVersion, Server, findPort;
24+
let devServerVersion, Server;
2525

2626
try {
2727
// eslint-disable-next-line node/no-extraneous-require
2828
devServerVersion = require('webpack-dev-server/package.json').version;
2929
// eslint-disable-next-line node/no-extraneous-require
3030
Server = require('webpack-dev-server/lib/Server');
31-
// eslint-disable-next-line node/no-extraneous-require
32-
findPort = require('webpack-dev-server/lib/utils/findPort');
3331
} catch (err) {
3432
logger.error(`You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`);
3533
process.exit(2);
@@ -71,9 +69,7 @@ export default async function startDevServer(
7169
for (const compilerWithDevServerOption of compilersWithDevServerOption) {
7270
const options = mergeOptions(compilerWithDevServerOption.options.devServer || {}, devServerCliOptions);
7371

74-
if (isDevServer4) {
75-
options.port = await findPort(options.port);
76-
} else {
72+
if (!isDevServer4) {
7773
const getPublicPathOption = (): string => {
7874
const normalizePublicPath = (publicPath): string =>
7975
typeof publicPath === 'undefined' || publicPath === 'auto' ? '/' : publicPath;
@@ -87,11 +83,6 @@ export default async function startDevServer(
8783
return normalizePublicPath(options.publicPath);
8884
}
8985

90-
// webpack-dev-server@4
91-
if (options.dev && options.dev.publicPath) {
92-
return normalizePublicPath(options.dev.publicPath);
93-
}
94-
9586
return normalizePublicPath(compilerWithDevServerOption.options.output.publicPath);
9687
};
9788
const getStatsOption = (): string | boolean => {

0 commit comments

Comments
 (0)