angular-cli how to add sass and or bootstrap?

后端 未结 5 1953
庸人自扰
庸人自扰 2020-12-25 13:57

I\'m trying out angular-cli and trying to get sass and bootstrap in the project. I\'ve read in the wiki that you can simply do:

ng install sass
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 14:22

    If you create your project with the angular-cli it comes with a scss preprocessor. If you have styles files you can just change the ext to scss and ng serve will compile them for you.

    When you create a project using the cli you can tell it that you want to use scss by

    ng new sassy-project --style=sass
    

    If you have an existing project Angular 2 to 5

    ng set defaults.styleExt scss
    

    If your project is Angular 6 and 7

    ng config schematics.@schematics/angular:component.styleext sass
    

    These tell the cli that when you generate new components with scss styles not css. It doesn't add a compiler or enable the compiler because there is already one there.

    Any existing components would need their style file extensions renamed.

    Additional documentation https://angular.io/cli

    Hope this helps

提交回复
热议问题