Skip to content

Commit c23286b

Browse files
refactor: logic
1 parent cdb509a commit c23286b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/serve/src/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ class ServeCommand {
113113
return;
114114
}
115115

116-
if ((compiler.options as WebpackDevServerOptions).devServer === undefined) {
117-
await cli.runWebpack(webpackCLIOptions as any, false);
118-
119-
return;
120-
}
121-
122116
const servers: (typeof DevServer)[] = [];
123117

124118
if (cli.needWatchStdin(compiler)) {
@@ -156,6 +150,12 @@ class ServeCommand {
156150
const usedPorts: number[] = [];
157151

158152
for (const compilerForDevServer of compilersForDevServer) {
153+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
154+
// @ts-ignore
155+
if (compilerForDevServer.options.devServer === false) {
156+
continue;
157+
}
158+
159159
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160160
const args = devServerFlags.reduce((accumulator: Record<string, any>, flag: any) => {
161161
accumulator[flag.name] = flag;
@@ -244,6 +244,11 @@ class ServeCommand {
244244
process.exit(2);
245245
}
246246
}
247+
248+
if (servers.length === 0) {
249+
cli.logger.error("No dev server configurations to run");
250+
process.exit(2);
251+
}
247252
},
248253
);
249254
}

packages/webpack-cli/src/webpack-cli.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,12 +2351,6 @@ class WebpackCLI implements IWebpackCLI {
23512351
isMultiCompiler: Array.isArray(config.options),
23522352
}),
23532353
);
2354-
2355-
// Handle when `devServer` is false
2356-
// TODO improve type on the webpack side
2357-
if ((item as any).devServer === false) {
2358-
delete item.devServer;
2359-
}
23602354
};
23612355

23622356
if (Array.isArray(config.options)) {

0 commit comments

Comments
 (0)