当在开发模式下启动Angular应用程序时,使用ng serve
,根据我在互联网上读到的,如果"sourceMap": true
是sat,源代码Map应该会在Web浏览器上立即出现。
这似乎不会给大多数开发人员带来麻烦。
但是,我并不是幸运的人,我的Firefox浏览器没有显示Angular生成的javascript的 typescript 副本。
我用的是Angular 14.
我是不是漏了什么参数设置?
下面的大部分内容都是由角插件编写的。但可能有些地方不准确或缺乏。
你能帮帮我吗?
- 系统配置json**
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2020",
"skipLibCheck": true,
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
- Angular . json**
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"etude": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/etude",
"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": [
"node_modules/ol/ol.css",
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": true,
"namedChunks": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "etude:build"
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "etude:build"
}
},
"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.css"
],
"scripts": []
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "etude:serve"
},
"configurations": {
"production": {
"devServerTarget": "etude:serve:production"
}
}
}
}
}
},
"cli": {
"analytics": false
}
}
- 包. json**
{
"name": "etude",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"buildProduction": "ng build --configuration production",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"openapi": "openapi-generator generate -g typescript-angular -i ../../../../metier-et-gestion/dev/GenerationOpenAPI/openapi/openapi.json -o ./openapi --skip-validate-spec"
},
"private": true,
"dependencies": {
"@angular/animations": "^14.2.12",
"@angular/common": "^14.2.12",
"@angular/compiler": "^14.2.12",
"@angular/core": "^14.2.12",
"@angular/forms": "^14.2.12",
"@angular/platform-browser": "^14.2.12",
"@angular/platform-browser-dynamic": "^14.2.12",
"@angular/router": "^14.2.12",
"@openapitools/openapi-generator-cli": "^1.0.13-4.3.1",
"ol": "^7.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.4.1",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^14.1.0",
"@angular-devkit/build-angular": "^14.2.10",
"@angular/cli": "^14.2.10",
"@angular/compiler-cli": "^14.2.12",
"@angular/language-service": "^14.2.12",
"@types/jasmine": "~4.3.1",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.2",
"jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"protractor": "~7.0.0",
"ts-node": "~10.9.1",
"tslint": "~6.1.0",
"typescript": "~4.6.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
},
"overrides": {
"codelyzer": {
"@angular/core": ">=14.0.0",
"@angular/compiler": ">=14.0.0"
}
}
}
1条答案
按热度按时间bvpmtnay1#
我的研究已经成功了,很高兴得到你的帮助。
必须在
angular.json
文件中进行两项更改:与我的第一篇文章相比,要解决我的问题,我必须:
1.在“架构”的“生成”部分中,添加开发配置:
1.在其
serve
部件上,执行以下更改:然后,一个经典的
ng serve
最终显示了 typescript 文件。