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

2

6

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?

Littlefield answered 7/5, 2019 at 20:52 Comment(0)
T
10

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.

Treva answered 7/5, 2019 at 22:29 Comment(0)
I
1

The command --prod is deprecated since Angular 12 and removed in Angular 14. Use:

ng build --configuration production --optimization=false

if ng build --prod --optimization=false doesn't work.

Isidore answered 27/6, 2023 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.