将MDC SASS文件添加到角4项目

时间:2017-06-09 20:04:36

标签: angular sass material-components

如何将MDC组件sass文件导入到angular 4项目中?编译器无法编译.scss文件,因为它们的@import语句不是相对的 - 它们只指向@material。例如,这是mdc-button.scss @import语句:

@import "@material/animation/variables";
@import "@material/animation/functions";
@import "@material/elevation/mixins";
@import "@material/ripple/mixins";
@import "@material/theme/mixins";
@import "@material/typography/mixins";

这会导致编译器失败,因为它找不到@material,因为该文件位于node_modules/@material/button/mdc-button.scss中,因此它需要实际@import "../animation/variables"等。

图书馆位于https://github.com/material-components/material-components-web/

1 个答案:

答案 0 :(得分:1)

根据您的sass工具,(我正在使用Koala)您必须将额外的路径信息添加到您的sass配置中:

// Sass project settings, you can edit it and set custom settings.
// An array of filesystem paths or importers which should be searched for     
//Sass templates imported with the @import directive. (I am on windows it might be 
//different for other O/S)

"includePaths": ["C:\\Users\\loggedInUser\\node_modules"],
    "requireLibs": []