Search code examples
angularobfuscationproduction-environment

How to disable minifying and uglifying/obfuscation in the production build of an Angular project?


I have a pesky error that occurs only in the production environment. But, Angular minifies and uglifies the production build. Is there any way to create an otherwise entirely production build, but without the hard to troubleshoot code?


Solution

  • From the Angular Docs it looks like you should be able to disable the optimizations by passing in a simple flag. Something like:

    ng build --configuration production --optimization=false

    An alternative approach would be to go into your angular.json file and update your configurations to "optimization": false. Although I suspect you're wanting to do this to help debug some code. In which case the flag is probably the more convenient solution.