2017-06-09 51 views
0

如何將MDC組件sass文件導入到我的angular 4項目中?編譯器無法編譯.scss文件,因爲它們的@import語句不是相對的 - 它們只是指向@material。例如,這裏是MDC-button.scss @import聲明:將MDC SASS文件添加到angular 4項目

@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

根據您的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": [] 
+0

Angular CLI處理編譯,但這仍然有效 –