@@ -55,7 +55,7 @@ import { type stringifyChunked } from "@discoveryjs/json-ext";
55
55
import { type Help , type ParseOptions } from "commander" ;
56
56
57
57
import { type CLIPlugin as CLIPluginClass } from "./plugins/cli-plugin" ;
58
- import * as console from "node:console" ;
58
+
59
59
const fs = require ( "fs" ) ;
60
60
const { Readable } = require ( "stream" ) ;
61
61
const path = require ( "path" ) ;
@@ -1933,19 +1933,23 @@ class WebpackCLI implements IWebpackCLI {
1933
1933
) ,
1934
1934
) ;
1935
1935
1936
- config . options = [ ] ;
1937
-
1938
- loadedConfigs . forEach ( ( loadedConfig ) => {
1939
- if ( Array . isArray ( loadedConfig . options ) ) {
1940
- for ( const item of loadedConfig . options ) {
1941
- ( config . options as WebpackConfiguration [ ] ) . push ( item ) ;
1942
- config . path . set ( options , [ loadedConfig . path ] ) ;
1936
+ if ( loadedConfigs . length === 1 ) {
1937
+ config . options = loadedConfigs [ 0 ] . options ;
1938
+ config . path . set ( loadedConfigs [ 0 ] . options , [ loadedConfigs [ 0 ] . path ] ) ;
1939
+ } else {
1940
+ config . options = [ ] ;
1941
+ loadedConfigs . forEach ( ( loadedConfig ) => {
1942
+ if ( Array . isArray ( loadedConfig . options ) ) {
1943
+ for ( const item of loadedConfig . options ) {
1944
+ ( config . options as WebpackConfiguration [ ] ) . push ( item ) ;
1945
+ config . path . set ( options , [ loadedConfig . path ] ) ;
1946
+ }
1947
+ } else {
1948
+ ( config . options as WebpackConfiguration [ ] ) . push ( loadedConfig . options ) ;
1949
+ config . path . set ( loadedConfig . options , [ loadedConfig . path ] ) ;
1943
1950
}
1944
- } else {
1945
- ( config . options as WebpackConfiguration [ ] ) . push ( loadedConfig . options ) ;
1946
- config . path . set ( loadedConfig . options , [ loadedConfig . path ] ) ;
1947
- }
1948
- } ) ;
1951
+ } ) ;
1952
+ }
1949
1953
} else {
1950
1954
// Prioritize popular extensions first to avoid unnecessary fs calls
1951
1955
const extensions = new Set ( [
0 commit comments