Skip to content

Commit a7874f7

Browse files
fix: single element config array in webpack.config.js now works in multi-compile mode
1 parent e364221 commit a7874f7

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

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

+3-20
Original file line numberDiff line numberDiff line change
@@ -1936,33 +1936,16 @@ class WebpackCLI implements IWebpackCLI {
19361936
config.options = [];
19371937

19381938
loadedConfigs.forEach((loadedConfig) => {
1939-
// TODO we should run webpack multiple times when the `--config` options have multiple values with `--merge`, need to solve for the next major release
1940-
if ((config.options as LoadableWebpackConfiguration[]).length === 0) {
1941-
config.options = loadedConfig.options as WebpackConfiguration;
1942-
} else {
1943-
if (!Array.isArray(config.options)) {
1944-
config.options = [config.options];
1945-
}
1946-
1947-
if (Array.isArray(loadedConfig.options)) {
1948-
for (const item of loadedConfig.options) {
1949-
config.options.push(item);
1950-
}
1951-
} else {
1952-
config.options.push(loadedConfig.options as WebpackConfiguration);
1953-
}
1954-
}
1955-
19561939
if (Array.isArray(loadedConfig.options)) {
1957-
for (const options of loadedConfig.options) {
1940+
for (const item of loadedConfig.options) {
1941+
(config.options as WebpackConfiguration[]).push(item);
19581942
config.path.set(options, [loadedConfig.path]);
19591943
}
19601944
} else {
1945+
(config.options as WebpackConfiguration[]).push(loadedConfig.options);
19611946
config.path.set(loadedConfig.options, [loadedConfig.path]);
19621947
}
19631948
});
1964-
1965-
config.options = config.options.length === 1 ? config.options[0] : config.options;
19661949
} else {
19671950
// TODO ".mts" is not supported by `interpret`, need to add it
19681951
// Prioritize popular extensions first to avoid unnecessary fs calls

0 commit comments

Comments
 (0)