WebPack 2 嵌套 SCSS

WebPack 2 nested SCSS

我不明白为什么我的嵌套 SCSS 代码不起作用。

嵌套 SCSS 示例

.line {
  .right {
    top: 0;
    height: 100%;
    width: 20px;
  }
}

Webpack2 加载器

exports.scss = {
        test: /\.scss$/,
        loaders: ['style-loader', 'css-loader?modules&importLoader=2&sourceMap&localIdentName=[name]__[local]___[hash:base64:5]!sass-loader' ]
}

如果我这样写就可以了

.line.right {
  top: 0;
  height: 100%;
  width: 20px;
}

*我暂时不想解压缩到另一个文件。

你缺少的是 &

.line {
  &.right {
    top: 0;
    height: 100%;
    width: 20px;
  }
}