天天看点

把CSS预编译器改成SASS

SASS 是一款非常好用的 CSS 预编译器,Bootstrap 官方从4.0开始已经切换到了 SASS。

目前(2017-10),@angular/cli 创建项目的时候没有自动使用 SASS 作为预编译器,我们需要自己手动修改一些配置文件,请按照以下步骤依次修改:

angular-cli.json 里面的 styles.css 后缀改成 .scss

把CSS预编译器改成SASS

enter image description here

当你后面再使用 ng g c *** 自动创建组件的时候,默认就会生成 .scss 后缀的样式文件了。

angular-cli.json 里面的 styleExt 改成 .scss

把CSS预编译器改成SASS

src 下面 style.css 改成 style.scss

把CSS预编译器改成SASS

app.component.scss

把CSS预编译器改成SASS

app.component.ts 里面对应修改

把CSS预编译器改成SASS

改完之后,重新 ng serve,打开浏览器查看效果。