Skip to content

Expose mangle option for UglifyJsPlugin #148

Closed
@Kezino

Description

@Kezino

Greetings!

Came across the problem of AgularJs minification. Some third party modules are not minified correctly with mangle option enabled. It throws error like Error: Unknown provider: tProvider <- t. Unfortunately, there is no way to disable mangle via Encore interface. Please, add the option. Thank you in advance!

P.S. For those, experiencing the same problem, here's how I solved it:

...

let config = Encore.getWebpackConfig(),
    webpack = require('webpack');

if (Encore.isProduction()) {
    let index;

    config.plugins.forEach((plugin, i) => {
        if (plugin instanceof webpack.optimize.UglifyJsPlugin) {
            index = i;
        }
    });

    if (index) {
        config.plugins.splice(index, 1);
    }

    config.plugins.push(new webpack.optimize.UglifyJsPlugin({
        mangle: false,
        sourceMap: !Encore.isProduction()
    }));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions