@@ -28,8 +28,6 @@ const { assert } = require('console');
2828const fsStatAsync = promisify ( fs . stat ) ;
2929const fsReadFileAsync = promisify ( fs . readFile ) ;
3030
31- const webpackMajorVersion = Number ( require ( 'webpack/package.json' ) . version . split ( '.' ) [ 0 ] ) ;
32-
3331class HtmlWebpackPlugin {
3432 /**
3533 * @param {HtmlWebpackOptions } [options]
@@ -164,9 +162,7 @@ class HtmlWebpackPlugin {
164162 hash : templateResult . mainCompilationHash
165163 } ;
166164
167- const childCompilationOutputName = webpackMajorVersion === 4
168- ? compilation . mainTemplate . getAssetPath ( this . options . filename , compiledEntries )
169- : compilation . getAssetPath ( this . options . filename , compiledEntries ) ;
165+ const childCompilationOutputName = compilation . getAssetPath ( this . options . filename , compiledEntries ) ;
170166
171167 // If the child compilation was not executed during a previous main compile run
172168 // it is a cached result
@@ -543,14 +539,10 @@ class HtmlWebpackPlugin {
543539 * if a path publicPath is set in the current webpack config use it otherwise
544540 * fallback to a relative path
545541 */
546- const webpackPublicPath = webpackMajorVersion === 4
547- ? compilation . mainTemplate . getPublicPath ( { hash : compilationHash } )
548- : compilation . getAssetPath ( compilation . outputOptions . publicPath , { hash : compilationHash } ) ;
549-
550- const isPublicPathDefined = webpackMajorVersion === 4
551- ? webpackPublicPath . trim ( ) !== ''
552- // Webpack 5 introduced "auto" - however it can not be retrieved at runtime
553- : webpackPublicPath . trim ( ) !== '' && webpackPublicPath !== 'auto' ;
542+ const webpackPublicPath = compilation . getAssetPath ( compilation . outputOptions . publicPath , { hash : compilationHash } ) ;
543+
544+ // Webpack 5 introduced "auto" - however it can not be retrieved at compile time
545+ const isPublicPathDefined = webpackPublicPath . trim ( ) !== '' && webpackPublicPath !== 'auto' ;
554546
555547 let publicPath =
556548 // If the html-webpack-plugin options contain a custom public path uset it
0 commit comments