![](/img/trans.png)
[英]How Do I Use Gulp to Minify and Autoprefix CSS files from SASS/SCSS
[英]SCSS, Compass and GULP: How to minify without breaking CSS?
我正在使用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
。
tags-bar
和ux-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(odd)
這可能是造成您的問題的原因。
有關該屬性的更多信息,請參見CSS-Tricks https://css-tricks.com/almanac/selectors/n/nth-last-of-type/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.