使用CSS模块时,为什么会在全局上下文中失败?

时间:2016-03-20 20:37:16

标签: sass webpack css-modules css-loader

core.scss

:global {

  $color-white: #fff;
  $color-primary: #6d5cae;
  $color-black: #000;
  $mix-percentage-dark: 81%;

  @mixin button($text-color, $background-color, $border-color) {
    .open .dropdown-toggle#{&} {
      background-color: mix($background-color, $color-black, $mix-percentage-dark);
      border-color: mix($background-color, $color-black, $mix-percentage-dark);
      color: $text-color;
    }
  }

  .btn-primary {
    @include button($color-white, $color-primary, $color-primary);
  }

}

WebPack配置:

webpackConfig.module.loaders.push({
  test: /\.scss$/,
  include: cssModulesRegex,
  loaders: [
    'style?sourceMap',
    'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader',
    'resolve-url',
    'sass?sourceMap'
  ]
})

错误:

  

模块构建失败:CssSyntaxError:postcss-modules-local-by-default:   src / styles / core.scss:1:0:之前缺少空格:global:global {

0 个答案:

没有答案