在 angular-cli 项目中使用 mdc sass 文件

use mdc sass files in angular-cli projects

我有一个项目使用 angular-cli。我正在使用 mdc components/。我想导入单个组件的 sass 文件。为此,

1) 我已经使用这个命令更改了默认的 styleExt

ng set defaults.styleExt scss

2) 将文件 style.css 重命名为 style.scss

3) 在 angular-cli.json 中更改为

"styles": [
        "styles.css"
      ],

"styles": [
        "styles.scss"
      ],

4) 添加了 stylePreprocessorOptions 配置以包含路径

"stylePreprocessorOptions": {
        "includePaths": [
          "node_modules"
        ]
 }

5) 最后在 style.scss 文件中导入

@import '~@material/button/mdc-button';

但这显示

ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader?{"ident":"postcss"}!./~/sass-loader/lib/loader.js?{"sourceMap":false,"precis
ion":8,"includePaths":["D://SK//Study//Material//MaterialWithAngularDemo//src//node_modules"]}!./src/styles.scss
Module build failed:
undefined
^
      File to import not found or unreadable: @material/theme/mixins.
Parent style sheet: D:/SK/Study/Material/MaterialWithAngularDemo/node_modules/@material/button/mdc-button.scss
      in D:\SK\Study\Material\MaterialWithAngularDemo\node_modules\@material\button\mdc-button.scss (line 17, column 1)
 @ ./src/styles.scss 4:14-187
 @ multi ./src/styles.scss

我是不是漏掉了什么?

includePath 中有错误而不是 node_modules,应该是 ../node_modules

"stylePreprocessorOptions": {
        "includePaths": [
          "../node_modules"
        ]
 }

更改后,它工作正常。