简体   繁体   中英

SASS output grouping selectors

SCSS

.clearfix.scss {
    background: #000;
}
.container1 {
    @extend .clearfix;
}
.container2 {
    @extend .clearfix;
}
.container3 {
    @extend .clearfix;
}

CSS Output:

.clearfix, .container1, .container2, .container3, .container4, .container5 {
    background: #000;
}

How can I remove this grouping selectors. Compilied by gulp. Using this task:

gulp.task('sass', function () {
    return gulp.src('scss/style.scss')
        .pipe(plumber())
        .pipe(sass())
        .pipe(autoprefixer(
            {
                browsers: ['last 15 versions'],
                cascade: true
            }
            ))
        .pipe(csscomb())
        .pipe(gulp.dest('css/'))
        .pipe(connect.reload()) });

You are seeing the intended output of the @extend feature. It combines extended selectors in order to result in a smaller file output. You could try using a mixin instead.

SCSS:

@mixin clearfix {
  background: #000;
}

.clearfix {
  @include clearfix;
}
.container1 {
  @include clearfix;
}
.container2 {
  @include clearfix;
}
.container3 {
  @include clearfix;
}

CSS output:

.clearfix {
  background: #000;
}

.container1 {
  background: #000;
}

.container2 {
  background: #000;
}

.container3 {
  background: #000;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM