How to disable bundle minification while building angular app?

122 views Asked by At

I have developed a angular project and have implemented SSR(Server Side Rendering) using angular-universal package. I am able to successfully serve my project with SSR at port localhost:4000, But I want to debug it as we do in in source of chrome developer tool. In SSR the main.js is served but I want all components code without minification.

Is there any way to stop of disable minification??

I have tried with --optimization=false, but no luck. I should be able to debug whichever component.ts i wish.

2

There are 2 answers

1
Naren Murali On BEST ANSWER

Generally we use the property source-map to true to debug.

--source-map - Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration | default: boolean false

build docs

0
John On

Minification is an optimization that is disabled by default in development mode.

The --optimization CLI option you mentioned is only available for ng build which is used for deployment. You should use ng serve for debugging purposes.

Here is a screenshot showing an exception triggered by a button click. In the Chrome DevTools console, you can see links to source files. When you click any link, the corresponding source file will open in the Sources tab with the line highlighted in yellow and cursor positioned at the right column.

enter image description here