@@ -20,7 +20,15 @@ function resolvePublicPath(compilation, filename) {
2020 return ensureTrailingSlash ( publicPath ) ;
2121}
2222
23- function addFileToAssets ( compilation , htmlPluginData , { filepath, typeOfAsset = 'js' , includeSourcemap = true , hash = false , publicPath } ) {
23+ function resolveOutput ( compilation , addedFilename , outputPath ) {
24+ if ( outputPath && outputPath . length ) {
25+ compilation . assets [ `${ outputPath } /${ addedFilename } ` ] = compilation . assets [ addedFilename ] ; // eslint-disable-line no-param-reassign
26+ delete compilation . assets [ addedFilename ] ; // eslint-disable-line no-param-reassign
27+ }
28+ }
29+
30+ function addFileToAssets ( compilation , htmlPluginData ,
31+ { filepath, typeOfAsset = 'js' , includeSourcemap = true , hash = false , publicPath, outputPath } ) {
2432 if ( ! filepath ) {
2533 const error = new Error ( 'No filepath defined' ) ;
2634 compilation . errors . push ( error ) ;
@@ -43,11 +51,17 @@ function addFileToAssets(compilation, htmlPluginData, { filepath, typeOfAsset =
4351
4452 htmlPluginData . assets [ typeOfAsset ] . unshift ( resolvedPath ) ;
4553
54+ resolveOutput ( compilation , addedFilename , outputPath ) ;
55+
4656 return resolvedPath ;
4757 } )
4858 . then ( ( ) => {
4959 if ( includeSourcemap ) {
50- return htmlPluginData . plugin . addFileToAssets ( `${ filepath } .map` , compilation ) ;
60+ return htmlPluginData . plugin . addFileToAssets ( `${ filepath } .map` , compilation )
61+ . then ( addedFilename => {
62+ resolveOutput ( compilation , addedFilename , outputPath ) ;
63+ return null ;
64+ } ) ;
5165 }
5266 return null ;
5367 } ) ;
0 commit comments