【问题标题】:WebPack 2 nested SCSSWebPack 2 嵌套 SCSS
【发布时间】:2017-10-30 18:33:18
【问题描述】:

我不明白为什么我的嵌套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;
}

*我现在不想解压到另一个文件。

【问题讨论】:

    标签: css module webpack sass webpack-style-loader


    【解决方案1】:

    你缺少的是&

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

    【讨论】:

    • 哈!我完全错过了这个。!它的工作 :D 我太愚蠢了 :D
    • 每个人都会遇到这种情况 :) 很高兴为您提供帮助
    猜你喜欢
    • 2020-01-24
    • 2022-01-16
    • 2017-06-01
    • 2016-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多