@@ -289,41 +289,41 @@ class CopyPlugin {
289289 logger . debug ( `found "${ from } "` ) ;
290290
291291 // `globby`/`fast-glob` return the relative path when the path contains special characters on windows
292- const absoluteFrom = path . resolve ( pattern . context , from ) ;
292+ const absoluteFilename = path . resolve ( pattern . context , from ) ;
293293 const relativeFrom = pattern . flatten
294- ? path . basename ( absoluteFrom )
295- : path . relative ( pattern . context , absoluteFrom ) ;
296- let webpackTo =
294+ ? path . basename ( absoluteFilename )
295+ : path . relative ( pattern . context , absoluteFilename ) ;
296+ let filename =
297297 pattern . toType === 'dir'
298298 ? path . join ( pattern . to , relativeFrom )
299299 : pattern . to ;
300300
301- if ( path . isAbsolute ( webpackTo ) ) {
302- webpackTo = path . relative ( compiler . options . output . path , webpackTo ) ;
301+ if ( path . isAbsolute ( filename ) ) {
302+ filename = path . relative ( compiler . options . output . path , filename ) ;
303303 }
304304
305- logger . log ( `determined that "${ from } " should write to "${ webpackTo } "` ) ;
305+ logger . log ( `determined that "${ from } " should write to "${ filename } "` ) ;
306306
307307 const sourceFilename = normalizePath (
308- path . relative ( pattern . compilerContext , absoluteFrom )
308+ path . relative ( pattern . compilerContext , absoluteFilename )
309309 ) ;
310310
311- return { absoluteFrom , sourceFilename, relativeFrom , webpackTo } ;
311+ return { absoluteFilename , sourceFilename, filename } ;
312312 } ) ;
313313
314314 return Promise . all (
315315 files . map ( async ( file ) => {
316316 // If this came from a glob, add it to the file watchlist
317317 if ( pattern . fromType === 'glob' ) {
318- logger . debug ( `add ${ file . absoluteFrom } as fileDependencies` ) ;
318+ logger . debug ( `add ${ file . absoluteFilename } as fileDependencies` ) ;
319319
320- compilation . fileDependencies . add ( file . absoluteFrom ) ;
320+ compilation . fileDependencies . add ( file . absoluteFilename ) ;
321321 }
322322
323323 let source ;
324324
325325 if ( cache ) {
326- const cacheEntry = await cache . getPromise ( file . relativeFrom , null ) ;
326+ const cacheEntry = await cache . getPromise ( file . sourceFilename , null ) ;
327327
328328 if ( cacheEntry ) {
329329 const isValidSnapshot = await CopyPlugin . checkSnapshotValid (
@@ -344,20 +344,20 @@ class CopyPlugin {
344344 startTime = Date . now ( ) ;
345345 }
346346
347- logger . debug ( `reading "${ file . absoluteFrom } " to write to assets` ) ;
347+ logger . debug ( `reading "${ file . absoluteFilename } " to write to assets` ) ;
348348
349349 let data ;
350350
351351 try {
352- data = await readFile ( inputFileSystem , file . absoluteFrom ) ;
352+ data = await readFile ( inputFileSystem , file . absoluteFilename ) ;
353353 } catch ( error ) {
354354 compilation . errors . push ( error ) ;
355355
356356 return ;
357357 }
358358
359359 if ( pattern . transform ) {
360- logger . log ( `transforming content for "${ file . absoluteFrom } "` ) ;
360+ logger . log ( `transforming content for "${ file . absoluteFilename } "` ) ;
361361
362362 if ( pattern . cacheTransform ) {
363363 const cacheDirectory = pattern . cacheTransform . directory
@@ -377,7 +377,7 @@ class CopyPlugin {
377377 if ( typeof pattern . cacheTransform . keys === 'function' ) {
378378 defaultCacheKeys = await pattern . cacheTransform . keys (
379379 defaultCacheKeys ,
380- file . absoluteFrom
380+ file . absoluteFilename
381381 ) ;
382382 } else {
383383 defaultCacheKeys = {
@@ -392,21 +392,21 @@ class CopyPlugin {
392392 const result = await cacache . get ( cacheDirectory , cacheKeys ) ;
393393
394394 logger . debug (
395- `getting cached transformation for "${ file . absoluteFrom } "`
395+ `getting cached transformation for "${ file . absoluteFilename } "`
396396 ) ;
397397
398398 ( { data } = result ) ;
399399 } catch ( _ignoreError ) {
400- data = await pattern . transform ( data , file . absoluteFrom ) ;
400+ data = await pattern . transform ( data , file . absoluteFilename ) ;
401401
402402 logger . debug (
403- `caching transformation for "${ file . absoluteFrom } "`
403+ `caching transformation for "${ file . absoluteFilename } "`
404404 ) ;
405405
406406 await cacache . put ( cacheDirectory , cacheKeys , data ) ;
407407 }
408408 } else {
409- data = await pattern . transform ( data , file . absoluteFrom ) ;
409+ data = await pattern . transform ( data , file . absoluteFilename ) ;
410410 }
411411 }
412412
@@ -416,10 +416,10 @@ class CopyPlugin {
416416 const snapshot = await CopyPlugin . createSnapshot (
417417 compilation ,
418418 startTime ,
419- file . relativeFrom
419+ file . sourceFilename
420420 ) ;
421421
422- await cache . storePromise ( file . relativeFrom , null , {
422+ await cache . storePromise ( file . sourceFilename , null , {
423423 source,
424424 snapshot,
425425 } ) ;
@@ -428,25 +428,25 @@ class CopyPlugin {
428428
429429 if ( pattern . toType === 'template' ) {
430430 logger . log (
431- `interpolating template "${ file . webpackTo } " for "${ file . relativeFrom } "`
431+ `interpolating template "${ file . filename } " for "${ file . sourceFilename } "`
432432 ) ;
433433
434434 // If it doesn't have an extension, remove it from the pattern
435435 // ie. [name].[ext] or [name][ext] both become [name]
436- if ( ! path . extname ( file . relativeFrom ) ) {
436+ if ( ! path . extname ( file . absoluteFilename ) ) {
437437 // eslint-disable-next-line no-param-reassign
438- file . webpackTo = file . webpackTo . replace ( / \. ? \[ e x t ] / g, '' ) ;
438+ file . filename = file . filename . replace ( / \. ? \[ e x t ] / g, '' ) ;
439439 }
440440
441441 // eslint-disable-next-line no-param-reassign
442442 file . immutable = / \[ (?: ( [ ^ : \] ] + ) : ) ? (?: h a s h | c o n t e n t h a s h ) (?: : ( [ a - z ] + \d * ) ) ? (?: : ( \d + ) ) ? \] / gi. test (
443- file . webpackTo
443+ file . filename
444444 ) ;
445445
446446 // eslint-disable-next-line no-param-reassign
447- file . webpackTo = loaderUtils . interpolateName (
448- { resourcePath : file . absoluteFrom } ,
449- file . webpackTo ,
447+ file . filename = loaderUtils . interpolateName (
448+ { resourcePath : file . absoluteFilename } ,
449+ file . filename ,
450450 {
451451 content : source . source ( ) ,
452452 context : pattern . context ,
@@ -455,27 +455,27 @@ class CopyPlugin {
455455
456456 // Bug in `loader-utils`, package convert `\\` to `/`, need fix in loader-utils
457457 // eslint-disable-next-line no-param-reassign
458- file . webpackTo = path . normalize ( file . webpackTo ) ;
458+ file . filename = path . normalize ( file . filename ) ;
459459 }
460460
461461 if ( pattern . transformPath ) {
462462 logger . log (
463- `transforming path "${ file . webpackTo } " for "${ file . absoluteFrom } "`
463+ `transforming path "${ file . filename } " for "${ file . absoluteFilename } "`
464464 ) ;
465465
466466 // eslint-disable-next-line no-param-reassign
467467 file . immutable = false ;
468468 // eslint-disable-next-line no-param-reassign
469- file . webpackTo = await pattern . transformPath (
470- file . webpackTo ,
471- file . absoluteFrom
469+ file . filename = await pattern . transformPath (
470+ file . filename ,
471+ file . absoluteFilename
472472 ) ;
473473 }
474474
475475 // eslint-disable-next-line no-param-reassign
476476 file . source = source ;
477477 // eslint-disable-next-line no-param-reassign
478- file . targetPath = normalizePath ( file . webpackTo ) ;
478+ file . filename = normalizePath ( file . filename ) ;
479479 // eslint-disable-next-line no-param-reassign
480480 file . force = pattern . force ;
481481
@@ -532,10 +532,9 @@ class CopyPlugin {
532532 . filter ( Boolean )
533533 . forEach ( ( asset ) => {
534534 const {
535+ absoluteFilename,
535536 sourceFilename,
536- absoluteFrom,
537- targetPath,
538- webpackTo,
537+ filename,
539538 source,
540539 force,
541540 } = asset ;
@@ -544,17 +543,17 @@ class CopyPlugin {
544543 /* istanbul ignore if */
545544 if ( typeof compilation . emitAsset !== 'function' ) {
546545 // eslint-disable-next-line no-param-reassign
547- compilation . assets [ targetPath ] = source ;
546+ compilation . assets [ filename ] = source ;
548547
549548 return ;
550549 }
551550
552- const existingAsset = compilation . getAsset ( targetPath ) ;
551+ const existingAsset = compilation . getAsset ( filename ) ;
553552
554553 if ( existingAsset ) {
555554 if ( force ) {
556555 logger . log (
557- `force updating "${ webpackTo } " to compilation assets from "${ absoluteFrom } "`
556+ `force updating "${ filename } " to compilation assets from "${ absoluteFilename } "`
558557 ) ;
559558
560559 const info = { copied : true , sourceFilename } ;
@@ -563,20 +562,18 @@ class CopyPlugin {
563562 info . immutable = true ;
564563 }
565564
566- compilation . updateAsset ( targetPath , source , info ) ;
565+ compilation . updateAsset ( filename , source , info ) ;
567566
568567 return ;
569568 }
570569
571- logger . log (
572- `skipping "${ webpackTo } ", because it already exists`
573- ) ;
570+ logger . log ( `skipping "${ filename } ", because it already exists` ) ;
574571
575572 return ;
576573 }
577574
578575 logger . log (
579- `writing "${ webpackTo } " to compilation assets from "${ absoluteFrom } "`
576+ `writing "${ filename } " to compilation assets from "${ absoluteFilename } "`
580577 ) ;
581578
582579 const info = { copied : true , sourceFilename } ;
@@ -585,7 +582,7 @@ class CopyPlugin {
585582 info . immutable = true ;
586583 }
587584
588- compilation . emitAsset ( targetPath , source , info ) ;
585+ compilation . emitAsset ( filename , source , info ) ;
589586 } ) ;
590587
591588 logger . debug ( 'end to adding additional assets' ) ;
0 commit comments