@@ -419,6 +419,9 @@ export default class Server {
419
419
this . options . inputFS ,
420
420
fileInRoot ,
421
421
[
422
+ '.proxyrc.cts' ,
423
+ '.proxyrc.mts' ,
424
+ '.proxyrc.ts' ,
422
425
'.proxyrc.cjs' ,
423
426
'.proxyrc.mjs' ,
424
427
'.proxyrc.js' ,
@@ -434,13 +437,24 @@ export default class Server {
434
437
435
438
const filename = path . basename ( configFilePath ) ;
436
439
437
- if (
438
- filename === '.proxyrc.js' ||
439
- filename === '.proxyrc.cjs' ||
440
- filename === '.proxyrc.mjs'
441
- ) {
442
- // $FlowFixMe
443
- // let cfg = (await import(configFilePath)).default;
440
+ if ( filename === '.proxyrc' || filename === '.proxyrc.json' ) {
441
+ let conf = await readConfig ( this . options . inputFS , configFilePath ) ;
442
+ if ( ! conf ) {
443
+ return this ;
444
+ }
445
+ let cfg = conf . config ;
446
+ if ( typeof cfg !== 'object' ) {
447
+ this . options . logger . warn ( {
448
+ message :
449
+ "Proxy table in '.proxyrc' should be of object type. Skipping..." ,
450
+ } ) ;
451
+ return this ;
452
+ }
453
+ for ( const [ context , options ] of Object . entries ( cfg ) ) {
454
+ // each key is interpreted as context, and value as middleware options
455
+ app . use ( createProxyMiddleware ( context , options ) ) ;
456
+ }
457
+ } else {
444
458
let cfg = await this . options . packageManager . require (
445
459
configFilePath ,
446
460
fileInRoot ,
@@ -459,23 +473,6 @@ export default class Server {
459
473
return this ;
460
474
}
461
475
cfg ( app ) ;
462
- } else if ( filename === '.proxyrc' || filename === '.proxyrc.json' ) {
463
- let conf = await readConfig ( this . options . inputFS , configFilePath ) ;
464
- if ( ! conf ) {
465
- return this ;
466
- }
467
- let cfg = conf . config ;
468
- if ( typeof cfg !== 'object' ) {
469
- this . options . logger . warn ( {
470
- message :
471
- "Proxy table in '.proxyrc' should be of object type. Skipping..." ,
472
- } ) ;
473
- return this ;
474
- }
475
- for ( const [ context , options ] of Object . entries ( cfg ) ) {
476
- // each key is interpreted as context, and value as middleware options
477
- app . use ( createProxyMiddleware ( context , options ) ) ;
478
- }
479
476
}
480
477
481
478
return this ;
0 commit comments