@@ -69,6 +69,7 @@ class WebpackCLI implements IWebpackCLI {
69
69
colors : WebpackCLIColors ;
70
70
logger : WebpackCLILogger ;
71
71
isColorSupportChanged : boolean | undefined ;
72
+ isConfigRegistered : boolean | undefined ;
72
73
builtInOptionsCache : WebpackCLIBuiltInOption [ ] | undefined ;
73
74
webpack ! : typeof webpack ;
74
75
program : WebpackCLICommand ;
@@ -1310,6 +1311,14 @@ class WebpackCLI implements IWebpackCLI {
1310
1311
cli . colors = cli . createColors ( color ) ;
1311
1312
} ) ;
1312
1313
1314
+ this . program . option ( "--config-registered" , "Disable interpret a config file." ) ;
1315
+ this . program . on ( "option:config-registered" , function ( ) {
1316
+ // @ts -expect-error shadowing 'this' is intended
1317
+ const { configRegistered } = this . opts ( ) ;
1318
+
1319
+ cli . isConfigRegistered = configRegistered ;
1320
+ } ) ;
1321
+
1313
1322
// Make `-v, --version` options
1314
1323
// Make `version|v [commands...]` command
1315
1324
const outputVersion = async ( options : string [ ] ) => {
@@ -1807,12 +1816,15 @@ class WebpackCLI implements IWebpackCLI {
1807
1816
}
1808
1817
1809
1818
async loadConfig ( options : Partial < WebpackDevServerOptions > ) {
1819
+ const configRegistered =
1820
+ typeof this . isConfigRegistered !== undefined && this . isConfigRegistered ;
1821
+
1810
1822
const interpret = require ( "interpret" ) ;
1811
1823
const loadConfigByPath = async ( configPath : string , argv : Argv = { } ) => {
1812
1824
const ext = path . extname ( configPath ) ;
1813
1825
const interpreted = Object . keys ( interpret . jsVariants ) . find ( ( variant ) => variant === ext ) ;
1814
1826
1815
- if ( interpreted ) {
1827
+ if ( interpreted && ! configRegistered ) {
1816
1828
const rechoir : Rechoir = require ( "rechoir" ) ;
1817
1829
1818
1830
try {
@@ -1904,7 +1916,7 @@ class WebpackCLI implements IWebpackCLI {
1904
1916
path : new WeakMap ( ) ,
1905
1917
} ;
1906
1918
1907
- if ( options . config && options . config . length > 0 ) {
1919
+ if ( options . config && options . config . length > 0 && configRegistered ) {
1908
1920
const loadedConfigs = await Promise . all (
1909
1921
options . config . map ( ( configPath : string ) =>
1910
1922
loadConfigByPath ( path . resolve ( configPath ) , options . argv ) ,
0 commit comments