oliviertassinari / serviceworker-webpack-plugin

Simplifies creation of a service worker to serve your webpack bundles. :recycle:
https://oliviertassinari.github.io/serviceworker-webpack-plugin/
MIT License
458 stars 76 forks source link

Don't detect minification using webpack.optimize #73

Closed shlomiassaf closed 6 years ago

shlomiassaf commented 6 years ago

In https://github.com/oliviertassinari/serviceworker-webpack-plugin/blob/master/src/index.js#L171-L173

With the new webpack, using this expression:

 return plugin instanceof webpack.optimize.UglifyJsPlugin

Will throw:

RemovedPluginError: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.

This should be change based on the version of webpack.

let minify;
if (Number(webpack.version[0]) >= 4) {
  minify = compiler.options.optimization && compiler.options.optimization.minimize
} else {
   minify = (compiler.options.plugins || []).some(plugin => {
      return plugin instanceof webpack.optimize.UglifyJsPlugin
    })
}
woutervanvliet commented 6 years ago

Thanks.

We have a workable fix for this on the next branch, but I think I like your fix better.

wendevlin commented 6 years ago

When are you going to deploy this fix for webpack v4?

andresmatasuarez commented 6 years ago

+1, is there a release date on schedule yet?

sibelius commented 6 years ago

is webpack 4 support ready?

woutervanvliet commented 6 years ago

Our fixes for webpack 4 breaks support with older versions of webpack entirely. Instead of using your suggestion, we're throwing an error on versions not supporting hooks (webpack < 4).