-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
🐞 Bug report
Command (mark with an x)
- new
- [x ] build
- serve
- test
- e2e
- generate
- add
- update
- lint
- xi18n
- run
- config
- help
- version
- doc
Is this a regression?
no
Description
With #15819 the CLI allows to define multiple configurations that get overlayed. However the merge process of the configs only does a shallow merge, which e.g. for fileReplacements means that all replacements in a previous config get overriden.
I suggest to do a deep merge on the configurations, not a shallow merge.
🔬 Minimal Reproduction
Example:
with this angular.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"proto-sites-next-app": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/proto-sites-next-app",
"index": "src/index.html",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"main": "src/main.ts",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.css",
"./node_modules/sample-sites-next/data/assets/lightTheme/main.css",
"src/styles.scss"
],
"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"
}
]
},
"edit": {
"outputPath": "dist/proto-sites-next-app-edit",
"fileReplacements": [
{
"replace": "src/app/app.bootstrap.module.ts",
"with": "src/app/app.bootstrap.edit.module.ts"
}
]
},
"view": {
"outputPath": "dist/proto-sites-next-app-view",
"fileReplacements": [
{
"replace": "src/app/app.bootstrap.module.ts",
"with": "src/app/app.bootstrap.view.module.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "proto-sites-next-app:build"
},
"configurations": {
"production": {
"browserTarget": "proto-sites-next-app:build:production"
},
"edit": {
"browserTarget": "proto-sites-next-app:build:edit-mode"
},
"view": {
"browserTarget": "proto-sites-next-app:build:view-mode"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "proto-sites-next-app: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.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "proto-sites-next-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "proto-sites-next-app:serve:production"
}
}
}
}
}},
"defaultProject": "proto-sites-next-app"
}I specify two new configs edit and view. These configs are logically orthogonal to production vs normal mode, so I would like to be able to build the application e.g. like this:
ng build --configuration=edit
and
ng build --configuration=production,edit
However the later does not work as expected because the file replacements for the environment as defined in the production config are overridden.
🌍 Your Environment
Angular CLI: 9.0.0-rc.9
Node: 10.17.0
OS: win32 x64
Angular: 9.0.0-rc.9
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.9
@angular-devkit/build-angular 0.900.0-rc.9
@angular-devkit/build-optimizer 0.900.0-rc.9
@angular-devkit/build-webpack 0.900.0-rc.9
@angular-devkit/core 9.0.0-rc.9
@angular-devkit/schematics 9.0.0-rc.9
@ngtools/webpack 9.0.0-rc.9
@schematics/angular 9.0.0-rc.9
@schematics/update 0.900.0-rc.9
rxjs 6.5.4
typescript 3.6.4
webpack 4.41.2
Anything else relevant?