Open MikeMitterer opened 4 years ago
Here they explain why this error occurs: https://github.com/jantimon/html-webpack-plugin/issues/1377
Try this:
const HtmlWebpackPlugin = require('html-webpack-plugin')
...
} else {
compiler.hooks.compilation.tap('HtmlBeautifyPlugin', compilation => {
let hook = compilation.hooks.htmlWebpackPluginAfterHtmlProcessing
? compilation.hooks.htmlWebpackPluginAfterHtmlProcessing
: HtmlWebpackPlugin.getHooks(compilation).beforeEmit
hook.tapAsync('HtmlBeautifyPlugin', (htmlPluginData, callback) => {
htmlPluginDataFunction(htmlPluginData, callback, this)
})
})
}
Try this:
const HtmlWebpackPlugin = require('html-webpack-plugin') ... } else { compiler.hooks.compilation.tap('HtmlBeautifyPlugin', compilation => { let hook = compilation.hooks.htmlWebpackPluginAfterHtmlProcessing ? compilation.hooks.htmlWebpackPluginAfterHtmlProcessing : HtmlWebpackPlugin.getHooks(compilation).beforeEmit hook.tapAsync('HtmlBeautifyPlugin', (htmlPluginData, callback) => { htmlPluginDataFunction(htmlPluginData, callback, this) }) }) }
I took your fix and forked https://www.npmjs.com/package/@nurminen/html-beautify-webpack-plugin
Works with webpack5 and latest HtmlWebpackPlugin 🙂
@rnurminen Thank you!
Installing html-webpack-plugin 4.0.1 leads to