sysgears / spinjs

SpinJS is now Zen! The project has been renamed and moved to Larix Framework.
https://github.com/sysgears/larix/tree/master/packages/zen
MIT License
43 stars 8 forks source link

Remove UglifyJsPlugin and expose Webpack v4 Optimization config #7

Closed clodal closed 6 years ago

clodal commented 6 years ago

Issue

In spinjs/src/plugins/WebpackPlugin.ts:54, we are manually adding UglifyJSPlugin like so:

53.   const UglifyJsPlugin = builder.require('uglifyjs-webpack-plugin');
54.   plugins.push(new UglifyJsPlugin(uglifyOpts));

However, since Webpack v4, setting mode to production should already perform UglifyJs optimisations by default (see webpack discussion).

Reference:

Including UglifyJsPlugin manually like how we do now, causes side-effects during the compilation, as I have faced in my downstream app and also evident from the stackoverflow question above.

Recommendation

Remove the UglifyJsPlugin and ensure minification is done by default with webpack v4’s optimization.minize. Also expose the optimization.minimizer config to allow end-users to override the default minimizer.

Reference:

— Happy to submit PR, thanks!

larixer commented 6 years ago

@clodal Thanks, I will be happy to accept PRs on both of your issues here. Please note that you can override optimization.minimize as well as any other webpack config parts via webpackConfig option already: https://github.com/sysgears/spinjs#webpack-babel-and-other-tool-specific-config-merging