@@ -70,7 +70,6 @@ class CopyPlugin {
70
70
}
71
71
72
72
static async runPattern (
73
- assetMap ,
74
73
compiler ,
75
74
compilation ,
76
75
logger ,
@@ -319,7 +318,6 @@ class CopyPlugin {
319
318
sourceFilename,
320
319
filename,
321
320
toType,
322
- priority : pattern . priority || 0 ,
323
321
} ;
324
322
} )
325
323
) ;
@@ -329,13 +327,7 @@ class CopyPlugin {
329
327
try {
330
328
assets = await Promise . all (
331
329
files . map ( async ( file ) => {
332
- const {
333
- absoluteFilename,
334
- sourceFilename,
335
- filename,
336
- toType,
337
- priority,
338
- } = file ;
330
+ const { absoluteFilename, sourceFilename, filename, toType } = file ;
339
331
const info =
340
332
typeof pattern . info === "function"
341
333
? pattern . info ( file ) || { }
@@ -585,12 +577,6 @@ class CopyPlugin {
585
577
result . filename = normalizePath ( result . filename ) ;
586
578
}
587
579
588
- if ( ! assetMap . has ( priority ) ) {
589
- assetMap . set ( priority , [ ] ) ;
590
- }
591
-
592
- assetMap . get ( priority ) . push ( result ) ;
593
-
594
580
// eslint-disable-next-line consistent-return
595
581
return result ;
596
582
} )
@@ -627,29 +613,38 @@ class CopyPlugin {
627
613
628
614
const assetMap = new Map ( ) ;
629
615
630
- try {
631
- await Promise . all (
632
- this . patterns . map ( ( item , index ) =>
633
- limit ( async ( ) =>
634
- CopyPlugin . runPattern (
635
- assetMap ,
616
+ await Promise . all (
617
+ this . patterns . map ( ( item , index ) =>
618
+ limit ( async ( ) => {
619
+ let assets ;
620
+
621
+ try {
622
+ assets = await CopyPlugin . runPattern (
636
623
compiler ,
637
624
compilation ,
638
625
logger ,
639
626
cache ,
640
627
item ,
641
628
index
642
- )
643
- )
644
- )
645
- ) ;
646
- } catch ( error ) {
647
- compilation . errors . push ( error ) ;
629
+ ) ;
630
+ } catch ( error ) {
631
+ compilation . errors . push ( error ) ;
648
632
649
- callback ( ) ;
633
+ return ;
634
+ }
650
635
651
- return ;
652
- }
636
+ if ( assets && assets . length > 0 ) {
637
+ const priority = item . priority || 0 ;
638
+
639
+ if ( ! assetMap . has ( priority ) ) {
640
+ assetMap . set ( priority , [ ] ) ;
641
+ }
642
+
643
+ assetMap . get ( priority ) . push ( ...assets ) ;
644
+ }
645
+ } )
646
+ )
647
+ ) ;
653
648
654
649
const assets = [ ...assetMap . entries ( ) ] . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] ) ;
655
650
0 commit comments