从Sass文件中的node_modules导入(使用ng-cli构建)

时间:2017-03-16 13:39:02

标签: angular angular2-cli

我正在使用ng-cli构建工具来组装我的Angular2应用程序。

我正在使用Sass来设计我的组件。在这些sass文件中,我想从bootstrap中导入一些sass内容。

我通过使用Sass @import使用node_modules下面相关引导程序文件的相对路径来实现此目的:

@import "../../../../node_modules/bootstrap/scss/_variables.scss";

这有点麻烦,如果我更改组件的目录结构会中断。

是否有更简洁的机制导入node_modules形式而没有相对路径?

似乎sass属性includePaths允许我将node_modules声明为包含路径,并允许我进行简洁的导入

@import "bootstrap/scss/_variables.scss";

如何指示ng-cli使用includePaths配置Sass?

1 个答案:

答案 0 :(得分:0)

尝试添加@import" ~bootstrap / scss / _variables.scss"在你的styles.scss