@@ -528,7 +528,11 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
528528 var i , chunk ;
529529 for ( i = 0 ; i < this . chunks . length ; i ++ ) {
530530 var chunk = this . chunks [ i ] ;
531- chunk . updateHash ( hash ) ;
531+ var chunkHash = new ( require ( "crypto" ) . Hash ) ( "md5" ) ;
532+ chunk . updateHash ( chunkHash ) ;
533+ this . chunkTemplate . updateHash ( chunkHash ) ;
534+ chunk . hash = chunkHash . digest ( "hex" ) ;
535+ hash . update ( chunk . hash ) ;
532536 }
533537 this . hash = hash = hash . digest ( "hex" ) ;
534538 for ( i = 0 ; i < this . modules . length ; i ++ ) {
@@ -544,6 +548,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
544548 for ( i = 0 ; i < this . chunks . length ; i ++ ) {
545549 chunk = this . chunks [ i ] ;
546550 chunk . files = [ ] ;
551+ var chunkHash = chunk . hash ;
547552 var source ;
548553 var file ;
549554 if ( chunk . entry ) {
@@ -561,18 +566,13 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
561566 this . assets [
562567 file = filename
563568 . replace ( Template . REGEXP_HASH , hash )
569+ . replace ( Template . REGEXP_CHUNKHASH , chunkHash )
564570 . replace ( Template . REGEXP_ID , chunk . id )
565571 . replace ( Template . REGEXP_NAME , chunk . name || "" )
566572 ] = source ;
567573 chunk . files . push ( file ) ;
568574 this . applyPlugins ( "chunk-asset" , chunk , file ) ;
569575 } else {
570- if ( this . cache ) {
571- var chunkHash = new ( require ( "crypto" ) . Hash ) ( "md5" ) ;
572- chunk . updateHash ( chunkHash ) ;
573- this . chunkTemplate . updateHash ( chunkHash ) ;
574- chunkHash = chunkHash . digest ( "hex" ) ;
575- }
576576 if ( this . cache && this . cache [ "c" + chunk . id ] && this . cache [ "c" + chunk . id ] . hash == chunkHash ) {
577577 source = this . cache [ "c" + chunk . id ] . source ;
578578 } else {
@@ -587,13 +587,15 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
587587 this . assets [
588588 file = chunkFilename
589589 . replace ( Template . REGEXP_HASH , hash )
590+ . replace ( Template . REGEXP_CHUNKHASH , chunkHash )
590591 . replace ( Template . REGEXP_ID , chunk . id )
591592 ] = source ;
592593 chunk . files . push ( file ) ;
593594 this . applyPlugins ( "chunk-asset" , chunk , file ) ;
594595 if ( namedChunkFilename && chunk . name ) {
595596 this . assets [
596597 file = namedChunkFilename
598+ . replace ( Template . REGEXP_CHUNKHASH , chunkHash )
597599 . replace ( Template . REGEXP_HASH , hash )
598600 . replace ( Template . REGEXP_ID , chunk . id )
599601 . replace ( Template . REGEXP_NAME , chunk . name || "" )
0 commit comments