Skip to content

Commit 2ce03b7

Browse files
committed
fix(serve): add merge handling for client object
1 parent d664890 commit 2ce03b7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/serve/src/getDevServerOptions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
export default function getDevServerOptions(compiler): any {
1010
let devServerOptions;
1111
if (compiler.compilers) {
12+
// devServer options could be found in any of the compilers,
13+
// so simply find the first instance and use it, if there is one
1214
const comp = compiler.compilers.find((comp) => comp.options.devServer);
1315
if (comp) {
1416
devServerOptions = comp.options.devServer;

packages/serve/src/mergeOptions.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,13 @@
99
export default function mergeOptions(cliOptions, devServerOptions): any {
1010
// CLI options should take precedence over devServer options,
1111
// and CLI options should have no default values included
12-
return { ...devServerOptions, ...cliOptions };
12+
const options = { ...devServerOptions, ...cliOptions };
13+
14+
if (devServerOptions.client && cliOptions.client) {
15+
// the user could set some client options in their devServer config,
16+
// then also specify client options on the CLI
17+
options.client = { ...devServerOptions.client, ...cliOptions.client };
18+
}
19+
20+
return options;
1321
}

0 commit comments

Comments
 (0)