Skip to content

Minify option auto-detection not working on webpack 4 #379

@edmorley

Description

@edmorley

Hi :-)

The options docs say:

  • minify: boolean. If set to true or false, the ServiceWorker's output will be minified or not accordingly. If set to something else, the ServiceWorker output will be minified if you are using webpack.optimize.UglifyJsPlugin in your configuration.
    Default: null

The check for that uses plugins to determine whether the user has activated minification:
https://github.com/NekR/offline-plugin/blob/v5.0.2/src/service-worker.js#L143-L146

However in webpack 4, UglifyJsPlugin is typically not added to plugins, but instead used via the new optimization.minimizers option (the plugin is added there by default, but people can override) which is toggled via the optimization.minimize bool:
https://github.com/webpack/webpack/blob/v4.6.0/lib/WebpackOptionsDefaulter.js#L270-L289
https://github.com/webpack/webpack/blob/v4.6.0/lib/WebpackOptionsApply.js#L334-L338

To allow the minify option auto-detection to work under both webpack 2-3 and webpack 4, I guess the conditional needs to be a combination of the existing plugins check and also optimization.minimize?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions