preload-webpack-plugin icon indicating copy to clipboard operation
preload-webpack-plugin copied to clipboard

tapAsync undefined in webpack4

Open nowaalex opened this issue 7 years ago • 13 comments

Building with PreloadWebpackPlugin enabled causes following error:


/home/alex/GIT/proj/node_modules/preload-webpack-plugin/build/index.js:163
          compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tapAsync(_this2.constructor.name, function (htmlPluginData, callback) {
                                                                  ^

TypeError: Cannot read property 'tapAsync' of undefined
    at /home/alex/GIT/proj/node_modules/preload-webpack-plugin/build/index.js:163:67

Project package versions: [email protected] [email protected]

nowaalex avatar Apr 25 '18 19:04 nowaalex

Can you try things out with the v3.0.0 alpha releases and let me know if you run into any issues there?

$ npm install --save-dev preload-webpack-plugin@next

jeffposnick avatar Apr 26 '18 18:04 jeffposnick

I already use version 3.0.0-alpha.3

nowaalex avatar May 02 '18 00:05 nowaalex

Which version of html-webpack-plugin are you using ?

toxic-johann avatar May 02 '18 01:05 toxic-johann

3.2.0, wrote on top

nowaalex avatar May 02 '18 08:05 nowaalex

Sorry for my mistake. I take a test on webpack v4.2.0 and html-webpack-plugin v3.2.0

It works well here.

I guess you may use preload-webpack-plugin before html-webpack-plugin. If you do that, the htmlWebpackPluginBeforeHtmlProcessing may missed because it has not been registered.

Can you make a check for this ? If not, can you provide us your webpack config ?

toxic-johann avatar May 02 '18 12:05 toxic-johann

Thank you! With preload plugin after html-webpack-plugin it works good!

nowaalex avatar May 02 '18 19:05 nowaalex

@toxic-johann, I am having the same issue, what do you mean by using preload-webpack-plugin before html-webpack-plugin? how can I change the order of plugin to build?
Thank you

mejiciel avatar Jun 13 '18 04:06 mejiciel

@mejiciel In the webpack plugins array. You should put html-webpack-plugin before preload-webpack-plugin.

toxic-johann avatar Jun 13 '18 05:06 toxic-johann

FWIW, The v3 branch has a new check for this, and will display in a meaningful error message when this happens: https://github.com/GoogleChromeLabs/preload-webpack-plugin/commit/89f6495dcd0f4a17db85566ebd3357f4375a6bce#diff-1fdf421c05c1140f6d71444ea2b27638R123

jeffposnick avatar Jun 13 '18 15:06 jeffposnick

This issue should remain opened until Webpack 4 support is released, just for better visibility.

alecmerdler avatar Jul 28 '18 23:07 alecmerdler

in which file should I put html-webpack-plugin before preload-webpack-plugin ?

surajkrishna avatar Sep 03 '18 07:09 surajkrishna

I am having same issue. using - "base-href-webpack-plugin": "^2.0.0", "html-webpack-plugin": "4.0.0-alpha.1",

subramn avatar Sep 05 '18 02:09 subramn

I'm using webpack 4.42.1 and I had the same issue, using "base-href-webpack-plugin": "^2.0.0", "html-webpack-plugin": "4.0.1". But I fixed it installing "html-webpack-plugin": "^3.2.0", and "base-href-webpack-plugin": "^2.0.0".

ayams avatar Mar 25 '20 22:03 ayams