本文介绍了浏览器中缺少 Angular 12 源映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们最近升级到 Angular 12 并面临浏览器源映射丢失的问题,因此我们无法调试我们的组件文件,因为没有.谁能建议我缺少什么?
We have upgraded to Angular 12 recently and facing a problem wherein the browser Source Map is missing and due to this we are unable to debug our component files as there aren't any.Can anyone suggest what I am missing?
推荐答案
Angular 12 更改了默认的ng build"使用生产"配置.你想要sourceMap"所以尝试添加一个开发"像这样在 angular.json 中配置
Angular 12 changed the default "ng build" to use the "production" configuration. You want "sourceMap" so try adding a "development" config in your angular.json like this
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
使用ng build -c development"作为目标,或者更改ng serve"的默认配置;例如.
Target with either "ng build -c development", or change your default configuration for "ng serve" eg.
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"development": {
"browserTarget": "app:build:development"
}
},
"defaultConfiguration": "development"
},
这篇关于浏览器中缺少 Angular 12 源映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!