@@ -117,7 +117,7 @@ class HtmlWebpackPlugin {
117117 * @param {string } templateFilename
118118 * @returns {Promise<string | (() => string | Promise<string>)> }
119119 */
120- evaluateCompilationResult ( source , templateFilename ) {
120+ evaluateCompilationResult ( source , publicPath , templateFilename ) {
121121 if ( ! source ) {
122122 return Promise . reject ( new Error ( 'The child compilation didn\'t provide a result' ) ) ;
123123 }
@@ -127,7 +127,7 @@ class HtmlWebpackPlugin {
127127 source += ';\nHTML_WEBPACK_PLUGIN_RESULT' ;
128128 }
129129 const templateWithoutLoaders = templateFilename . replace ( / ^ .+ ! / , '' ) . replace ( / \? .+ $ / , '' ) ;
130- const vmContext = vm . createContext ( { HTML_WEBPACK_PLUGIN : true , require : require , ...global } ) ;
130+ const vmContext = vm . createContext ( { HTML_WEBPACK_PLUGIN : true , require : require , htmlWebpackPluginPublicPath : publicPath , ...global } ) ;
131131 const vmScript = new vm . Script ( source , { filename : templateWithoutLoaders } ) ;
132132 // Evaluate code and cast to string
133133 let newSource ;
@@ -327,7 +327,7 @@ function hookIntoCompiler (compiler, options, plugin) {
327327 // Once everything is compiled evaluate the html factory
328328 // and replace it with its content
329329 return ( 'compiledEntry' in templateResult )
330- ? plugin . evaluateCompilationResult ( templateResult . compiledEntry . content , options . template )
330+ ? plugin . evaluateCompilationResult ( templateResult . compiledEntry . content , htmlPublicPath , options . template )
331331 : Promise . reject ( new Error ( 'Child compilation contained no compiledEntry' ) ) ;
332332 } ) ;
333333 const templateExectutionPromise = Promise . all ( [ assetsPromise , assetTagGroupsPromise , templateEvaluationPromise ] )
0 commit comments