Angular sourceMap 损坏
Angular sourceMap broken
我刚刚将我的 angular 项目更新为 angular 版本 12,由于某种原因,sourcemap 停止工作,现在当我在控制台上出错时无法调试。这是我的 tsconfig 和 angular.js:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"noImplicitAny": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2015",
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"strictNullChecks": false,
"noImplicitReturns": true,
"noUnusedLocals": true,
"types": ["node", "jest", "cypress"],
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "es2019", "dom"],
"paths": {
"@models/*": ["src/app/models/*"],
"@services/*": ["src/app/services/*"],
"@store/*": ["src/app/store/*"],
"@functions/*": ["src/app/functions/*"],
"@shared/*": ["src/app/shared/*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true
},
"exclude": ["e2e/**/.*ts"]
}
angular.js上
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"defaultCollection": "@ngrx/schematics",
"analytics": false
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ms-mr-ui": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@ngrx/schematics:component": {
"style": "scss",
"changeDetection": "OnPush"
},
"@ngrx/schematics:directive": {},
"@ngrx/schematics:pipe": {},
"@ngrx/schematics:service": {},
"@ngrx/schematics:module": {
"commonModule": false
},
"@ngrx/schematics:class": {
"skipTests": true
},
"@ngrx/schematics:store": {
"statePath": "store",
"stateInterface": "State"
},
"@ngrx/schematics:action": {
"creators": true,
"flat": false,
"api": true
},
"@ngrx/schematics:reducer": {
"creators": true,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:effect": {
"creators": false,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:entity": {
"creators": false,
"flat": false,
"spec": true
},
"@ngrx/schematics:feature": {
"creators": true,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:container": {
"style": "scss",
"changeDetection": "OnPush",
"testDepth": "unit",
"skipTests": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "mr",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ms-mr-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/styles.scss",
"node_modules/@aposin/ng-aquila/css/utilities.css",
"node_modules/@allianz/ngx-ndbx/css/ndbx-base.css",
"node_modules/@allianz/ngx-ndbx/css/themes/ndbx.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"development": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"es5": {
"tsConfig": "tsconfigs/tsconfig.es5.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/scss/styles.scss",
"src/styles/fonts/IBMPlex/ibmplex.css",
"src/styles/fonts/inter-web-hinted/inter.css",
"node_modules/material-icons/iconfont/material-icons.css"
],
"scripts": [],
"stylePreprocessorOptions": {
"includePaths": ["src/styles/scss"]
},
"codeCoverageExclude": [
"/**/*mock*.ts",
"/**/*validators.ts",
"/**/*module.ts",
"/**/*api.service.ts",
"/**/models/**",
"/**/constants/**"
]
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ms-mr-ui:build"
},
"configurations": {
"production": {
"browserTarget": "ms-mr-ui:build:production"
},
"development": {
"browserTarget": "ms-mr-ui:build:development"
},
"es5": {
"browserTarget": "ms-mr-ui:build:es5"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ms-mr-ui:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["tsconfig.app.json", "tsconfigs/tsconfig.spec.json", "tsconfigs/tsconfig.e2e.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "ms-mr-ui"
}
我认为 Angular 12,他们提供没有源映射的应用程序的生产版本。
尝试:ng serve --sourcemap
查看源地图。看看这个 link,似乎 --sourcemap
标志已被弃用,它必须通过浏览器构建器来完成,我认为它在 configurations
中的 angular.json
中。
尝试添加:
"serve": {
...
"defaultConfiguration": "development"
},
并更改:
"architect": {
"build": {
"configurations": {
...
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true
}
我刚刚将我的 angular 项目更新为 angular 版本 12,由于某种原因,sourcemap 停止工作,现在当我在控制台上出错时无法调试。这是我的 tsconfig 和 angular.js:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"noImplicitAny": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2015",
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"strictNullChecks": false,
"noImplicitReturns": true,
"noUnusedLocals": true,
"types": ["node", "jest", "cypress"],
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "es2019", "dom"],
"paths": {
"@models/*": ["src/app/models/*"],
"@services/*": ["src/app/services/*"],
"@store/*": ["src/app/store/*"],
"@functions/*": ["src/app/functions/*"],
"@shared/*": ["src/app/shared/*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true
},
"exclude": ["e2e/**/.*ts"]
}
angular.js上
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"defaultCollection": "@ngrx/schematics",
"analytics": false
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ms-mr-ui": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@ngrx/schematics:component": {
"style": "scss",
"changeDetection": "OnPush"
},
"@ngrx/schematics:directive": {},
"@ngrx/schematics:pipe": {},
"@ngrx/schematics:service": {},
"@ngrx/schematics:module": {
"commonModule": false
},
"@ngrx/schematics:class": {
"skipTests": true
},
"@ngrx/schematics:store": {
"statePath": "store",
"stateInterface": "State"
},
"@ngrx/schematics:action": {
"creators": true,
"flat": false,
"api": true
},
"@ngrx/schematics:reducer": {
"creators": true,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:effect": {
"creators": false,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:entity": {
"creators": false,
"flat": false,
"spec": true
},
"@ngrx/schematics:feature": {
"creators": true,
"flat": false,
"api": true,
"spec": true
},
"@ngrx/schematics:container": {
"style": "scss",
"changeDetection": "OnPush",
"testDepth": "unit",
"skipTests": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "mr",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ms-mr-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/styles.scss",
"node_modules/@aposin/ng-aquila/css/utilities.css",
"node_modules/@allianz/ngx-ndbx/css/ndbx-base.css",
"node_modules/@allianz/ngx-ndbx/css/themes/ndbx.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"development": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"es5": {
"tsConfig": "tsconfigs/tsconfig.es5.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles/scss/styles.scss",
"src/styles/fonts/IBMPlex/ibmplex.css",
"src/styles/fonts/inter-web-hinted/inter.css",
"node_modules/material-icons/iconfont/material-icons.css"
],
"scripts": [],
"stylePreprocessorOptions": {
"includePaths": ["src/styles/scss"]
},
"codeCoverageExclude": [
"/**/*mock*.ts",
"/**/*validators.ts",
"/**/*module.ts",
"/**/*api.service.ts",
"/**/models/**",
"/**/constants/**"
]
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ms-mr-ui:build"
},
"configurations": {
"production": {
"browserTarget": "ms-mr-ui:build:production"
},
"development": {
"browserTarget": "ms-mr-ui:build:development"
},
"es5": {
"browserTarget": "ms-mr-ui:build:es5"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ms-mr-ui:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["tsconfig.app.json", "tsconfigs/tsconfig.spec.json", "tsconfigs/tsconfig.e2e.json"],
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "ms-mr-ui"
}
我认为 Angular 12,他们提供没有源映射的应用程序的生产版本。
尝试:ng serve --sourcemap
查看源地图。看看这个 link,似乎 --sourcemap
标志已被弃用,它必须通过浏览器构建器来完成,我认为它在 configurations
中的 angular.json
中。
尝试添加:
"serve": {
...
"defaultConfiguration": "development"
},
并更改:
"architect": {
"build": {
"configurations": {
...
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true
}