tradingview / webpack-uglify-parallel

Identical to standard uglify webpack plugin, with an option to build multiple files in parallel
MIT License
144 stars 5 forks source link

Support for unminified-webpack-plugin #2

Open AndyOGo opened 7 years ago

AndyOGo commented 7 years ago

How about compatability/support for unminified-webpack-plugin?

w0rse commented 7 years ago

Hi! You mean to be able to generate unminified files in parallel?

AndyOGo commented 7 years ago

@w0rse Hi, yes exactly, but without having webpack being run twice, just in one go.

kfeinUI commented 7 years ago

unminified-webpack-plugin checks for the presence of the UglifyJsPlugin in the configuration with an instanceof test.

I worked around this by doing the following:

const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
UglifyJsParallelPlugin.prototype = Object.assign(new webpack.optimize.UglifyJsPlugin(), UglifyJsParallelPlugin.prototype);
w0rse commented 7 years ago

Looks a bit hacky :) We should work with unminified-webpack-plugin author to remove the strong check for UglifyJsPlugin.

kfeinUI commented 7 years ago

Conceptually, extending UglifyJsPlugin makes sense. The difficulty is that its not designed/executed in a friendly way to support this. If they broke up the monolithic apply() into smaller pieces, you could easily reuse what they already offer without duplication. My workaround effectively overrides the bulk of the code of the original, but makes the type checking happy.