Closed
Description
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 commentedon Jun 4, 2014
No opinions? 😸
sokra commentedon Jun 4, 2014
Indeed I have. This need to be changed. The
UglifyJsPlugin
should only use uglify-js.There are four options I have in mind:
module.loader: { }
which adds properties to the loader context.LoaderContextPlugin(context)
which adds properties to the loader context.LoaderMinimizePlugin()
or similar, which only setsminimize
on the loader context.LoaderOptionsPlugin(regExp, query/obj)
which adds options a specific loaders via query.The
debug
option would also be affected by this.jhnns commentedon Jun 4, 2014
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 aLoaderMinimizePlugin()
which uses internally theLoaderOptionsPlugin()
?gaearon commentedon Jan 8, 2015
Wow, this is quite unexpected!
jhnns commentedon Feb 3, 2016
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 commentedon Feb 3, 2016
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 commentedon Feb 19, 2016
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 commentedon Feb 19, 2016
only in the 2.x version. It's a breaking change which cannot be done on 1.x version.
15 remaining items