GoogleChromeLabs / preload-webpack-plugin

Please use https://github.com/vuejs/preload-webpack-plugin instead.
Apache License 2.0
2.16k stars 144 forks source link

tapAsync undefined in webpack4 #68

Open nowaalex opened 6 years ago

nowaalex commented 6 years ago

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: html-webpack-plugin@3.2.0 webpack@4.6.0

jeffposnick commented 6 years ago

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
nowaalex commented 6 years ago

I already use version 3.0.0-alpha.3

toxic-johann commented 6 years ago

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

nowaalex commented 6 years ago

3.2.0, wrote on top

toxic-johann commented 6 years ago

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 ?

nowaalex commented 6 years ago

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

mejiciel commented 6 years ago

@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

toxic-johann commented 6 years ago

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

jeffposnick commented 6 years ago

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

alecmerdler commented 5 years ago

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

surajkrishna commented 5 years ago

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

subramn commented 5 years ago

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

ayams commented 4 years ago

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".