Html-webpack-plugin: Webpack 4 > 'html-webpack-plugin-before-html-generation' hook not found.

Created on 1 Mar 2018  路  11Comments  路  Source: jantimon/html-webpack-plugin

Hi,

First of all, I want to say great work for this plugin and thanks for the webpack 4 support 馃憤.
For the context, I want to use webpack 4 for my tool create-cozy-app, but I still have an issue with this plugin.

Description

Using the last version of html-webpack-plugin 3.0.3 and webpack 4.1.2, I still have an issue about a not found hook.

Error Message & Stack Trace

Plugin could not be registered at 'html-webpack-plugin-before-html-generation'. Hook was not found.
    BREAKING CHANGE: There need to exist a hook at 'this.hooks'. To create a compatiblity layer for this hook, hook into 'this._pluginCompat'.

Thanks by advance.

Most helpful comment

The reason for this issue is a incompatible plugin or loader.
As I don't know which incompatible loader you installed I don't know why it is generating the error.
But if you knew the plugin or loader which is not compatible to the Webpack 4 plugin system it would be better to let the author knew instead of posting it here :)

All 11 comments

The new compilation hooks for Webpack 4 are:

Sync

  • htmlWebpackPluginAlterChunks

Async

  • htmlWebpackPluginBeforeHtmlGeneration
  • htmlWebpackPluginBeforeHtmlProcessing
  • htmlWebpackPluginAlterAssetTags
  • htmlWebpackPluginAfterHtmlProcessing
  • htmlWebpackPluginAfterEmit

Still working my way through the new Webpack 4 plugin world one console.log() at a time myself, but it seems you (or your html-webpack-plugin-hook-using dependencies) need to do something like this to use the new hooks:

function myPlugin() {
  this.hooks.compilation.tap('myPlugin', compilation => {
    compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tapAsync('myPlugin', (data, cb) => {
      // Do stuff
      cb()
    })
  })
}

Exactly that's the new webpack plugin system

Ok, my bad, I wasn't looking at the right place.
I did actually have this issue due to the svg-sprite-loader usage on my side.
Sorry for the noise and thank you for taking time to reply my question @insin and @jantimon 馃憤
I close this issue.

Hi, sorry, i also have this issue and can't see an answer on this thread on how to resolve it?

馃啓

The reason for this issue is a incompatible plugin or loader.
As I don't know which incompatible loader you installed I don't know why it is generating the error.
But if you knew the plugin or loader which is not compatible to the Webpack 4 plugin system it would be better to let the author knew instead of posting it here :)

yes, you are right! I fixed this problem :) the problem is in FaviconsWebpackPlugin

@kotchuprik
How did you fix it. Since i have the same issue after upgrading to webpack 4.

Webpack is using the official nodejs depreacte util:
https://nodejs.org/api/util.html#util_util_deprecate_function_string

Add process.traceDeprecation = true; to your webpack config to see details about the reason for that warning.

@4iAmAve my problem was in old version of FaviconsWebpackPlugin

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klinki picture klinki  路  3Comments

ruoyiqing picture ruoyiqing  路  3Comments

var-bp picture var-bp  路  3Comments

yyx990803 picture yyx990803  路  4Comments

MatthewKosloski picture MatthewKosloski  路  3Comments