// https://segmentfault.com/a/1190000016292354
// https://angular.cn/guide/workspace-config
{
// 注解和驗(yàn)證JSON數(shù)據(jù)格式的工具
// 比如可以自動(dòng)填充屬性或?qū)傩灾? "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
// 用來創(chuàng)建析工程的位置。絕對(duì)路徑或相對(duì)于工作區(qū)目錄的路徑
// 使用 ng generate application myDemo, 就會(huì)在 angular-dave/projects 目錄下生成 myDemo 項(xiàng)目
"newProjectRoot": "projects",
// 這個(gè)屬性包含了工作空間中所有項(xiàng)目的配置信息
// 如果如上生成 myDemo, 那么在這里還有與 angular-dave 同一層級(jí)的 myDemo 的配置
"projects": {
"angular-dave": {
// 該屬性有 application 和 library 兩種選擇
"projectType": "application",
"schematics": {
// 在項(xiàng)目級(jí)別統(tǒng)一進(jìn)行配置
// 比如在這里,配置了所有的 component 都使用 scss
// 可試著查看其它的配置項(xiàng),因?yàn)橛?$schema, 會(huì)幫你自動(dòng)補(bǔ)全相關(guān)屬性
"@schematics/angular:component": {
"style": "scss"
}
},
// 指定了項(xiàng)目文件的根文件夾,可能為空,但是它指定了一個(gè)特定的文件夾
// 如果如上生成 myDemo, 那么 myDemo 的如下幾個(gè)屬性值路徑會(huì)有所不同
"root": "",
"sourceRoot": "src",
// 當(dāng)CLI創(chuàng)建 `component`或者`directive`時(shí),使用該屬性 來區(qū)別他們
"prefix": "app",
// 為本項(xiàng)目的各個(gè)構(gòu)建器目標(biāo)配置默認(rèn)值
"architect": {
// 為 ng build 命令的選項(xiàng)配置默認(rèn)值
"build": {
// 每個(gè)目標(biāo)對(duì)象都指定了該目標(biāo)的 builder,它是 architect (建筑師)所運(yùn)行工具的 npm 包
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-dave",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
// 包含一些用于添加到項(xiàng)目的全局上下文中的靜態(tài)文件路徑
// 每個(gè) build 目標(biāo)配置都可以包含一個(gè) assets 數(shù)組,它列出了當(dāng)你構(gòu)建項(xiàng)目時(shí)要復(fù)制的文件或文件夾。
// 默認(rèn)情況下,會(huì)復(fù)制 src/assets/ 文件夾和 src/favicon.ico
"assets": [
"src/favicon.ico",
"src/assets"
],
// 包含一些要添加到項(xiàng)目全局上下文中的樣式文件(即全局樣式)
"styles": [
"src/styles.scss"
],
// 包含一些 JavaScript 腳本文件,用于添加到項(xiàng)目的全局上下文中。
// 這些腳本的加載方式和在 index.html 的 <script> 標(biāo)簽中添加是完全一樣的。
"scripts": []
},
// configurations 部分可以為目標(biāo)命名并指定備用配置
"configurations": {
// you can use that configuration by specifying the --configuration="production" or the --prod="true" option.
// ng build --prod=true|false
// Shorthand for "--configuration=production".
// When true, sets the build configuration to the production target.
// By default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination.
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts"
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
// 全部或部分應(yīng)用的默認(rèn)尺寸預(yù)算的類型和閾值。
// 當(dāng)構(gòu)建的輸出達(dá)到或超過閾值大小時(shí),你可以將構(gòu)建器配置為報(bào)告警告或錯(cuò)誤
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
// 覆蓋構(gòu)建默認(rèn)值,并為 ng serve 命令提供額外的服務(wù)器默認(rèn)值
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular-dave:build"
},
"configurations": {
"production": {
"browserTarget": "angular-dave:build:production"
}
}
},
// 為 ng xi18n 命令所用到的 ng-xi18n 工具選項(xiàng)配置了默認(rèn)值
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-dave:build"
}
},
// 覆蓋測(cè)試時(shí)的構(gòu)建選項(xiàng)默認(rèn)值,并為 ng test 命令提供額外的默認(rèn)值以供運(yùn)行測(cè)試
"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"
],
"scripts": []
}
},
// 為 ng lint 命令配置了默認(rèn)值,用于對(duì)項(xiàng)目源文件進(jìn)行代碼分析
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
// 覆蓋了構(gòu)建選項(xiàng)默認(rèn)值,以便用 ng e2e 命令構(gòu)建端到端測(cè)試應(yīng)用
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "angular-dave:serve"
},
"configurations": {
"production": {
"devServerTarget": "angular-dave:serve:production"
}
}
}
}
}
},
"defaultProject": "angular-dave"
}
angular.json
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。