For Angular 6, be sure to consult the Official documentation
Note: If you are using versions of @angular/cli
prior to 6.0.0-beta.6
, make sure to use ng set
instead of ng config
.
For pre-existing projects
If you have an existing angular-cli project with default css
styles, there are some steps you need to take:
- Switch the default style extension to
scss
You can manually change it in .angular-cli.json
(for Angular 5.x and older) or angular.json
(for Angular 6+) or run the command:
ng config defaults.styleExt=scss
If you encounter an error stating "Value cannot be found," use this command:
ng config schematics.@schematics/angular:component.styleext scss
(*source: Angular CLI SASS options)
Rename your current .css
files to .scss
(e.g., styles.css and app/app.component.css)
Ensure that the CLI is directed to locate styles.scss
Manually update the file extensions in apps[0].styles
within angular.json
- Adjust the components to find your new styling files
Modify the styleUrls
in your components to match the updated file names
For upcoming projects
Following @Serginho's suggestion, specify the style extension when initiating the ng new
command
ng new your-project-name --style=scss
To establish a default for all future projects, execute the following command:
ng config --global defaults.styleExt=scss