Tuesday, 14 March 2017

Webpack Uglify Plugin removes library (Markup.js)

I use webpack to collect and combine all my required JS libraries. I noticed that one of them (Markup.js) is missing from the final minified js file.

After some trial and error I traced the problem to this part of code:

plugins.push(new webpack.optimize.UglifyJsPlugin({
        output: {
            comments: true, // just for testing
        },
        compress: {
            warnings: false,
        },

        // skip pre-minified libs
        exclude: [/\.min\.js$/gi],
...

If I delete this part, the Markup.js library is part of the final (non-minified) JS file as expected. But when I use the uglify plugin, the Markup.js part is no longer there.

I though this might be because Markup.js is never "used" in the project source code, but using

compress: {
    warnings: false,
    unused: false,
    dead_code: false,
},

makes no difference.

All I want is for the final file to have the same content as before, just minified. The uglify plugin should not make any assumptions about what parts of the code are really "needed".

How can I achieve this?



via user3265879

No comments:

Post a Comment