Skip to content

Instantly share code, notes, and snippets.

@israeljrs
Last active March 16, 2017 12:51
Show Gist options
  • Save israeljrs/cc0cd238ef5206f3607ee4ba15383f8b to your computer and use it in GitHub Desktop.
Save israeljrs/cc0cd238ef5206f3607ee4ba15383f8b to your computer and use it in GitHub Desktop.
how add sass to ng-cli

How add sass to angular 2 cli

New project

For new projects we can set the options --style=sass or --style=scss according to the desired flavor SASS/SCSS

$ ng new project --style=sass

then install node-sass,

$ npm install node-sass --save-dev

Updating existing projects

To make angular-cli to compile sass files with node-sass, I had to run,

$ npm install node-sass --save-dev 

which installs node-sass. Then

$ ng set defaults.styleExt sass

to set the default styleExt to sass (or) change styleExt to sass in angular-cli.json,

"defaults": {
     "styleExt": "sass",
}

Although it generated compiler errors.

ERROR in multi styles
Module not found: Error: Can't resolve '/home/user/projects/project/src/styles.css' in '/home/user/projects/project'
 @ multi styles 

which was fixed by changing the lines of angular-cli.json,

"styles": [
        "styles.css"
      ],

to

"styles": [
        "styles.sass"
      ],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment