Open KhaydarshinAleksandr opened 2 years ago
Hello, I think that expression for check webpack 5.x version is incorrect.
function hookPlugin(compiler, onEmit) { if (compiler.hooks && compiler.hooks.thisCompilation && compiler.hooks.processAssets) { // webpack 5.x ... } else if (compiler.hooks) { // webpack 4.x ... } else { // older versions ... } }
The main problem is that processAssets is Compilation hook (link), not a Compiler. Therefore compiler.hooks.processAssets will always be falsy.
processAssets
compiler.hooks.processAssets
My suggestion is to use webpack.version to find out the correct version.
webpack.version
Hello, I think that expression for check webpack 5.x version is incorrect.
The main problem is that
processAssets
is Compilation hook (link), not a Compiler. Thereforecompiler.hooks.processAssets
will always be falsy.My suggestion is to use
webpack.version
to find out the correct version.