-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular-devkit/architect): add implementation for defaultConfig…
…uration With this change, the architect can be configured to use a default configuration when it's not provided as part of the target. Consider the below, where `defaultConfiguration` is configured to `production`. Running `ng build` will be invoked with "production" configuration. ```js "build": { "builder": "@angular-devkit/build-angular:browser", "defaultConfiguration": "production", "options": { ... }, "configurations": { "production": { ... } } } ```
- Loading branch information
1 parent
f7e3e23
commit 1da359a
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/legacy-cli/e2e/tests/misc/target-default-configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expectFileToExist } from '../../utils/fs'; | ||
import { ng } from '../../utils/process'; | ||
import { updateJsonFile } from '../../utils/project'; | ||
import { expectToFail } from '../../utils/utils'; | ||
|
||
export default async function () { | ||
await updateJsonFile('angular.json', workspace => { | ||
const build = workspace.projects['test-project'].architect.build; | ||
build.defaultConfiguration = undefined; | ||
build.options = { | ||
...build.options, | ||
optimization: false, | ||
buildOptimizer: false, | ||
outputHashing: 'none', | ||
sourceMap: true, | ||
}; | ||
}); | ||
|
||
await ng('build'); | ||
await expectFileToExist('dist/test-project/main.js'); | ||
await expectFileToExist('dist/test-project/main.js.map'); | ||
|
||
// Add new configuration and set "defaultConfiguration" | ||
await updateJsonFile('angular.json', workspace => { | ||
const build = workspace.projects['test-project'].architect.build; | ||
build.defaultConfiguration = 'defaultConfiguration'; | ||
build.configurations.defaultConfiguration = { | ||
sourceMap: false, | ||
}; | ||
}); | ||
|
||
await ng('build'); | ||
await expectFileToExist('dist/test-project/main.js'); | ||
await expectToFail(() => expectFileToExist('dist/test-project/main.js.map')); | ||
} |