Skip to content

Why does the UglifyJsPlugin affect other loaders? #283

Closed
@jhnns

Description

@jhnns
Member

That's more of a question than an issue.

I was wondering why optimize.minimize has been removed in favor of the UglifyJsPlugin? I prefer plugins over big configuration options, but it seems not logically to me that the UglifyJsPlugin switches all other loaders (even those which don't generate JS) into min-mode.

Activity

jhnns

jhnns commented on Jun 4, 2014

@jhnns
MemberAuthor

No opinions? 😸

added and removed on Jun 4, 2014
sokra

sokra commented on Jun 4, 2014

@sokra
Member

Indeed I have. This need to be changed. The UglifyJsPlugin should only use uglify-js.

There are four options I have in mind:

  • An option module.loader: { } which adds properties to the loader context.
  • A plugin LoaderContextPlugin(context) which adds properties to the loader context.
  • A plugin LoaderMinimizePlugin() or similar, which only sets minimize on the loader context.
  • A plugin LoaderOptionsPlugin(regExp, query/obj) which adds options a specific loaders via query.

The debug option would also be affected by this.

jhnns

jhnns commented on Jun 4, 2014

@jhnns
MemberAuthor

The debug option would also be affected by this.

Makes sense.

The LoaderOptionsPlugin(regExp, query/obj) sounds reasonable. But I think most of the time you'll want to minify just all modules. So maybe there should be a LoaderMinimizePlugin() which uses internally the LoaderOptionsPlugin()?

gaearon

gaearon commented on Jan 8, 2015

@gaearon
Contributor

Wow, this is quite unexpected!

jhnns

jhnns commented on Feb 3, 2016

@jhnns
MemberAuthor

Lately, I was thinking about this again. This is still misleading for newcomers. Wouldn't it be better to remove all the minification stuff from the loaders?

I think the best solution would be to have different plugins for all the various web-compatible output files, like MinifyJS, MinifyCSS, MinifyHTML, MinifyImages that are applied on all files that are about to be emitted. However, the minification should happen before the hash calculation.

sokra

sokra commented on Feb 3, 2016

@sokra
Member

I think the best solution would be to have different plugins for all the various web-compatible output files, like MinifyJS, MinifyCSS, MinifyHTML, MinifyImages that are applied on all files that are about to be emitted. However, the minification should happen before the hash calculation.

That doesn't work for inlined files... i. e. CSS or HTML inlined into JS.

Btw. This was changed in webpack. UglifyJs now only minimized js. A LoaderOptionsPlugin allows to switch on minimizing for loaders.

barroudjo

barroudjo commented on Feb 19, 2016

@barroudjo

I wholeheartedly agree with the issue, so it's great if this has been solved, but I haven't seen it for the stable (1.x.x) version. Has this only been solved for the beta version ?
And by the way the fact that activating UglyfyJsPlugin currently puts all loaders in minify mode should be documented somewhere.

sokra

sokra commented on Feb 19, 2016

@sokra
Member

only in the 2.x version. It's a breaking change which cannot be done on 1.x version.

15 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bebraw@jellyfish-tom@jhnns@gaearon@sokra

        Issue actions

          Why does the UglifyJsPlugin affect other loaders? · Issue #283 · webpack/webpack