css - SCSS、 compass 和 GULP : How to minify without breaking CSS?

标签 css sass gulp compass gulp-sass

我正在使用 Gulp-Compass并想缩小我的 CSS。

当我这样做时,下面的代码

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

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

缩小为:

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

:nth-type 部分会混淆浏览器,因此 ux-panel-hidden 不会被读取。

JSFiddle with minified code

JSfildde with non-minified code

tags-barux-panel 在单独的 _scss 文件中,所以我不确定为什么缩小将它们放在一起。

我该如何解决?

这是我的 Gulp 代码:

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"
        }));
});

最佳答案

:nth-last-of-type 不是有效的语法,因为它需要传递一个参数,例如。 :nth-last-of-type(奇数)

这可能会导致您的问题。

更多关于 CSS-Tricks 属性的阅读 https://css-tricks.com/almanac/selectors/n/nth-last-of-type/

关于css - SCSS、 compass 和 GULP : How to minify without breaking CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30817836/

相关文章:

html - css 不适用于没有 href 属性的标签

无论选项如何,gulp-autoprefixer 都不输出 -webkit-flex

angularjs - 执行 gulp 任务时无法在 karma 配置文件上加载 "mocha"框架

html - 将我的导航栏链接居中

css - 使用 rgba 颜色覆盖背景图像,使用 CSS3 过渡

html - 如何将两个 div 放在同一行上并让它们响应?

ionic-framework - 如何将 css 应用到 ionic 警报内的文本?

sass - Normalise.css 与波本苦酒一起

deployment - 如何使用 gulp 递归复制目录?

css - 动态重新缩放的 div 网格