2 thoughts on “Uglify not working properly in production build.

  1. @umasgn it is not very polite to open an issue on a project called “Webpack” claiming in the title another project “Uglify” (yes UglifyJS is a separate project) doesn’t work and putting almost no effort into explaining the problem. UglifyJS is a separate project – even the UglifyJS plug-in is not webpack but a plug-in.

    Since quite a large community is using this combination with success every day its very likely that the issue is the code you’re trying to minify.

    Just a few questions which you could have provided answers for in your very first attempt:

    • What’s your Webpack configuration and options?
    • What are the errors you see?
    • Are you using/building some framework/library? Only from researching your profile I assume you’re an Angular-guy.
    • If that’s the case have you researched Angular issues? For example there is a similar issue for Angular2 right here.

    Angular team did not take into consideration what UglifyJS docs tell you: you shouldn’t rely on Function.name when mangling your code, because mangling is what shortens long names – including function names – to a, b or c. So assuming a function to have a particular name after mangling just fails. Now you also know why your code doesn’t get so much minified anymore after setting mangle: false: because you actually disabled minification.

    However the UglifyJS developers were clever enough to provide an option letting you exclude function names from mangling: by researching you find mangle: true together with keep_fnames=true may produce minified code that runs. Go try it out. If it works, please be at least polite enough to come back and tell webpack people that they can close this issue.

Comments are closed.