package.json

"scripts": {
  "compile:sass": "node-sass sass/main.scss css/style.css -w"
}

main.scss
@import "abstracts/variables";
@import "base/typography";

_variables.scss
$color-light-grey: #777;
$color-white: #fff;

_typography.scss
body {
  color: $color-light-grey;
}
.heading-primary {
  color: $color-white;
}

现在我的问题是,当我尝试使用npm run compile:sass进行编译时,它将引发以下错误:

最佳答案

看起来上面的代码中有两个错误:

  • 您导入"abstracts/variables",但是至少在文本中,文件名似乎是_variables.scss(缺少“s”)
  • 您应该先导入"abstracts/variables",然后再进行其他操作。

  • 像那样:
    @import "abstracts/variables";
    @import "base/typography";
    

    关于css - 使用node-sass编译SCSS时出现 undefined variable 错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47506906/

    10-12 00:08
    查看更多