参考中文官网https://angular.cn/
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1, // 该配置文件的版本。
"newProjectRoot": "projects", //用来创建新工程的位置。绝对路径或相对于工作区目录的路径。
"projects": { // 对于工作区中的每个项目(应用或库)都会包含一个子分区,子分区中是每个项目的配置项。
"my-app": { // 子分区一的配置
"projectType": "application", // "application" 或 "library" 之一。
"schematics": { //一组原理图,用于定制 ng generate 子命令在本工作空间中的默认选项。参见稍后的生成器原理图。
"@schematics/angular:component": {
"style": "less"
}
},
"root": "", // 该项目的根文件夹,相对于工作区文件夹的路径。初始应用的值为空,因为它位于工作区的顶层。
"sourceRoot": "src", // 该项目源文件的根文件夹。
"prefix": "app", // Angular 所生成的选择器的前缀字符串。可以自定义它,以作为应用或功能区的标识。
"architect": { // 为本项目的各个构建器目标配置默认值。
"build": { // ng build 命令的选项配置默认值
"builder": "@angular-devkit/build-angular:browser", // 运行工具的 npm 包
"options": { // 配置该目标的默认选项
"outputPath": "dist/my-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [ // 项目资产配置
{ "glob": "**/*", // 一个 node-glob 它使用 input 作为基准目录
"input": "src/assets/", // 相对于工作空间根目录的路径
"ignore": ["**/*.svg"], // 排除了 assets 文件夹中的某些特定文件,防止它们被复制到 build 中
"output": "/assets/" //相对于 outDir 的路径(默认为 dist/project-name )。为了杜绝安全隐患,CLI 永远不会在项目输出路径之外写文件
}, // node_modules/some-package/images/ 中的内容将会复制到 dist/some-package/ 中
"src/favicon.ico",
"src/assets"
],
"styles": [
{ "input": "src/external-module/styles.scss",
"inject": false, // 将捆绑包从注入中排除
"bundleName": "external-module"//入口点命名捆绑包
},
"src/styles.less"
],
"scripts": []
},
"configurations": { // 为目标命名并指定备用配置
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": { // 覆盖构建默认值,并为 ng serve 命令提供额外的服务器默认值
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my-app:build"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production"
}
}
},
"extract-i18n": { // 为 ng xi18n 命令所用到的 ng-xi18n 工具选项配置了默认值,该命令用于从源代码中提取带标记的消息串,并输出翻译文件
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "my-app:build"
}
},
"test": { // 节会覆盖测试时的构建选项默认值,并为 ng 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.less"
],
"scripts": []
}
},
"lint": { // 为 ng lint 命令配置了默认值,用于对项目源文件进行代码分析
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": { // 覆盖了构建选项默认值,以便用 ng e2e 命令构建端到端测试应用
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "my-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "my-app:serve:production"
}
}
}
},
"server" { // 用于为使用 ng run <project>:server 命令创建带服务器端渲染的 Universal 应用配置默认值
// /app-shell 部分使用 ng run <project>:app-shell 命令为渐进式 Web 应用(PWA)配置创建应用外壳的默认值
}
}
},
"defaultProject": "my-app", //当命令中没有指定参数时,要使用的默认工程名。当你用 ng new 在新的工作区中创建新应用时,该应用就会一直作为此工作区的默认项目,除非你到这里修改它。
"cli": {
"analytics": "497d02f8-80fa-429c-b6e7-0c7b8ab5dcd9"
}
}