I've read the documentation, which says that if I want to use scss
I have to run the following command:
ng set defaults.styleExt scss
But when I do that and make that file, I still receive this error in my console:
styles.bundle.js:33Uncaught Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/Egen/Code/angular/src/styles.css'(…)
For Angular 6 check the Official documentation
Note: For
@angular/cli
versions older than6.0.0-beta.6
useng set
in place ofng config
.For existing projects
In an existing angular-cli project that was set up with the default
css
styles you will need to do a few things:scss
if you get an error:
Value cannot be found.
use the command:(*source: Angular CLI SASS options)
Rename your existing
.css
files to.scss
(i.e. styles.css and app/app.component.css)Point the CLI to find styles.scss
For future projects
As @Serginho mentioned you can set the style extension when running the
ng new
commandIf you want to set the default for all projects you create in the future run the following command:
As of ng6 this can be accomplished with the following code added to
angular.json
at the root level:Manually change in
.angular.json
:CSS Preprocessor integration for Angular CLI: 6.0.3
When generating a new project you can also define which extension you want for style files:
Or set the default style on an existing project:
Angular CLI Documentation for all major CSS preprocessors
For Angular 6,
note: @schematics/angular is the default schematic for the Angular CLI