How to debug Angular in prod server?

2020-02-26 04:01发布

问题:

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 ?

回答1:

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

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



回答2:

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,**
                 --------


回答3:

If you are deploying on test server than do not use --prod so if error comes it will show u complete detail of error but your application will run in dev mode