Customization for Angular 9+ (version 6+ below)
1) To configure settings globally, paste the snippet in the root of angular.json
.
2) For project-specific settings, place the snippet in the root of a specific project (projects.your-project-name
) in angular.json
.
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
Explore all configurable options per file type at Schematic Options:
"schematics": {
"@schematics/angular:component": {
"changeDetection": "Default",
"entryComponent": false,
"export": false,
"flat": false,
"inlineStyle": false,
"inlineTemplate": false,
"module": "",
"prefix": "",
"selector": "",
"skipImport": false,
"spec": true,
"style": "css",
"viewEncapsulation": "Emulated",
"skipTests": "false"
},
...
},
For Angular 6+
1) Copy the snippet to the root of angular.json
, (to apply changes globally).
2) Or copy it to a specific project's root (projects.your-project-name
) within angular.json
(for project-specific configurations).
"schematics": {
"@schematics/angular:component": {
"styleext": "scss",
"spec": false
},
...
},
Check out all customizable options for each file type in Schematic Options:
"schematics": {
"@schematics/angular:component": {
"changeDetection": "Default",
...
},
...
},
Angular CLI Configuration using Angular CLI
CAUTION:
The command
ng set defaults.spec.component false
triggers an error:
get/set have been deprecated in favor of the config command.
To resolve this issue, replace ng set
with ng config
.
Utilizing the Angular CLI (config command specifics):
The specifications for generating specs, inline templates, inline styling, etc., are now stored within
schematics.@schematics/angular.<file-type>.<setting>
in
angular.json
.
Type
ng config schematics.@schematics/angular.component.spec false
to set up spec configurations for components. This command inserts the setting in the schematics property of
angular.json
.
Angular CLI workspace file (angular.json) on Angular Github
View Schematic options inside schema.json
Learn How to Perform X in Angular CLI v6