Sass和webpack - @for循环错误

时间:2016-08-27 10:36:36

标签: sass webpack

这是我的代码:

@for $i from 1 through 3 {
   .myclass-#{$i} {
      /* ... */
   }
}

我使用webpack并收到此错误:

ERROR in ./~/css-loader!./~/sass-loader!./~/postcss-loader?pack=cleaner!./path/style.scss
/path/to/my/file/style.scss:649:22: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
@for $i from 1 through 3 {
    .myclass-#{$i} {
               ^

有没有办法解决它?

我使用此配置:

{
   test: /\.scss$/,
   loaders: ["style", "css", "sass", "postcss?pack=cleaner"]
},

由于

1 个答案:

答案 0 :(得分:0)

发生这种情况是因为您有样式加载器和CSS加载器。我猜这导致了重新处理。删除样式加载器,它应该可以工作。至少那是我遇到类似错误的问题