Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Angular in prod server?

In the development environment I can debug with the Chrome source tab , but in the prod server I use the dist folder content after running ng build --prod. This folder contains compiled code so if there is a problem in the production I don't know how to debug to find the problem.

Is it possible to debug through the production compiled code ?

like image 705
David Avatar asked Aug 21 '17 14:08

David


People also ask

What is the use of Sourcemap in Angular?

At its core, a source map is a JSON file that contains all the necessary information to map the transpiled code back to the original sources. Pretty cool! Technically a source map is just a JSON file that contains the following fields: version: indicates the source map spec version.


2 Answers

Update: You can tryng build --prod --sourcemap

For the previous versions of angular-2 this would work , ng build --prod --sourcemap

For Angular 12

ng build --source-map 

For Angular 8

As mentioned in the comments

ng build --prod --sourceMap 
like image 122
DeborahK Avatar answered Sep 26 '22 08:09

DeborahK


In Angualr CLI 6 options seems to be changed as

ng build --prod --source-map 

Or else you can enable source maps in angular.json by setting the sourceMap:true in production configurations

"configurations": {             "production": {               "optimization": true,               "outputHashing": "all",               **"sourceMap": false,**                  -------- 
like image 23
nandithakw Avatar answered Sep 26 '22 08:09

nandithakw