SCSS, Compass and GULP: How to minify without breaking CSS?

571 views Asked by At

I am using Gulp-Compass and want to minify my CSS.

When I do this, the following code

.tags-bar .sub-bullet:nth-last-of-type {
display:none; 
}

.ux-panel-hidden{
display:none;
}

becomes minified to:

.tags-bar .sub-bullet:nth-last-of-type,.ux-panel-hidden{display:none}

The :nth-type part confuses the browser, so the ux-panel-hidden doesn't get read.

JSFiddle with minified code

JSfildde with non-minified code

tags-bar and ux-panel are in separate _scss files, so I am not sure why the minfication brings them together.

How can I fix it?

Here is my Gulp Code:

gulp.task('compass', function() {
    return gulp.src('frontend/build/css/*.scss')
        .pipe(compass({
            css: 'frontend/dist/css',
            sass: 'frontend/build/css',
            image: 'frontend/images/',
            font: 'stylesheets/fonts',
            require: ['susy', 'breakpoint'],
            bundle_exec: true
        }))
        .pipe(plumber({
            errorHandler: onError
        }))
        .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
        .pipe(gulp.dest('frontend/dist/css'))
        .pipe(rename({
         suffix: '.min'
        }))
        .pipe(minifycss())
        .pipe(gulp.dest('frontend/dist/css'))
        .pipe(notify({ // Add gulpif here
            sound: "Pop"
        }));
});
1

There are 1 answers

0
mistermist On BEST ANSWER

:nth-last-of-type is not valid syntax since it requires an argument to be passed eg. :nth-last-of-type(odd)

This may be causing your issue.

More reading on the property at CSS-Tricks https://css-tricks.com/almanac/selectors/n/nth-last-of-type/