@@ -277,9 +277,9 @@ export class Kaba
277
277
jsConfig = {
278
278
common : this . buildWebpackCommon ( cliConfig ) ,
279
279
module : this . buildModern
280
- ? this . buildWebpackConfig ( cliConfig , true )
280
+ ? this . buildWebpackConfigs ( cliConfig , true )
281
281
: null ,
282
- legacy : this . buildWebpackConfig ( cliConfig , false ) ,
282
+ legacy : this . buildWebpackConfigs ( cliConfig , false ) ,
283
283
javaScriptDependenciesFileName : this . javaScriptDependenciesFileName ,
284
284
basePath : path . join ( this . outputPaths . base , this . outputPaths . js ) ,
285
285
} ;
@@ -423,7 +423,7 @@ export class Kaba
423
423
/**
424
424
* Builds the specialized webpack config for a legacy / module build
425
425
*/
426
- private buildWebpackConfig ( cliConfig : kaba . CliConfig , isModule : boolean ) : Partial < webpack . Configuration >
426
+ private buildWebpackConfigs ( cliConfig : kaba . CliConfig , isModule : boolean ) : Partial < webpack . Configuration > [ ]
427
427
{
428
428
const babelLoader = {
429
429
loader : "babel-loader?cacheDirectory" ,
@@ -454,10 +454,7 @@ export class Kaba
454
454
isModule ? "tsconfig.modern.json" : "tsconfig.legacy.json" ,
455
455
) ;
456
456
457
- return {
458
- // entry
459
- entry : entries ,
460
-
457
+ let configTemplate = {
461
458
// output
462
459
output : {
463
460
path : path . join ( this . outputPaths . base , this . outputPaths . js , isModule ? "modern" : "legacy" ) ,
@@ -498,23 +495,6 @@ export class Kaba
498
495
test : / \. ( s v g | t x t ) $ / ,
499
496
loader : "raw-loader" ,
500
497
} ,
501
-
502
- // ESLint
503
- {
504
- test : / \. m ? j s x ? $ / ,
505
- // only lint files that are in the project dir & exclude tests, vendor and node_modules
506
- include : ( path ) => path . startsWith ( this . cwd ) && ! / n o d e _ m o d u l e s | t e s t s | v e n d o r / . test ( path ) ,
507
- loader : "eslint-loader" ,
508
- options : {
509
- cache : true ,
510
- configFile : path . join ( this . libRoot , "configs/.eslintrc.yml" ) ,
511
- fix : cliConfig . fix ,
512
- parser : "babel-eslint" ,
513
- quiet : ! cliConfig . lint ,
514
- // always only emit a warning, so to actually never fail the webpack build
515
- emitWarning : true ,
516
- } ,
517
- } ,
518
498
] ,
519
499
} ,
520
500
@@ -529,6 +509,37 @@ export class Kaba
529
509
} ) ,
530
510
] ,
531
511
} ;
512
+
513
+ return Object . keys ( entries ) . map ( ( entryFile , index ) =>
514
+ {
515
+ let config = Object . assign ( { } , configTemplate , {
516
+ entry : {
517
+ [ entryFile ] : entries [ entryFile ] ,
518
+ } ,
519
+ } ) as Partial < webpack . Configuration > ;
520
+
521
+ if ( isModule && undefined !== config . module )
522
+ {
523
+ ( config . module . rules as any ) . push ( {
524
+ // ESLint
525
+ test : / \. m ? j s x ? $ / ,
526
+ // only lint files that are in the project dir & exclude tests, vendor and node_modules
527
+ include : ( path ) => path . startsWith ( this . cwd ) && ! / n o d e _ m o d u l e s | t e s t s | v e n d o r / . test ( path ) ,
528
+ loader : "eslint-loader" ,
529
+ options : {
530
+ cache : true ,
531
+ configFile : path . join ( this . libRoot , "configs/.eslintrc.yml" ) ,
532
+ fix : cliConfig . fix ,
533
+ parser : "babel-eslint" ,
534
+ quiet : ! cliConfig . lint ,
535
+ // always only emit a warning, so to actually never fail the webpack build
536
+ emitWarning : true ,
537
+ } ,
538
+ } ) ;
539
+ }
540
+
541
+ return config ;
542
+ } ) ;
532
543
}
533
544
}
534
545
0 commit comments