[英]Minify CSS with Gulp via .pipe
是否可以使用clean-css這樣的插件,以便在每次刷新/保存頁面時都縮小CSS。 我如何通過管道鏈接它,使其到達最小的dist文件夾? 謝謝你的幫助!
這是當前代碼:
gulp.task('styles', function(){
return gulp.src('css/style.css')
.pipe(postcss([cssImport, mixins, cssvars, nested, hexrgba, autoprefixer]))
.on('error', function(errorInfo){
console.log(errorInfo.toString());
this.emit('end');
})
//stylesheet destination folder
.pipe(gulp.dest('dist/styles'));
});
您可以使用uglifycss:
uglifycss = require('gulp-uglifycss');
gulp.task('styles', function(){
return gulp.src('css/style.css')
.pipe(postcss([cssImport, mixins, cssvars, nested, hexrgba, autoprefixer]))
.on('error', function(errorInfo){
console.log(errorInfo.toString());
this.emit('end');
})
.pipe(uglifycss({
"maxLineLen": 80,
"uglyComments": true
}))
//stylesheet destination folder
.pipe(gulp.dest('dist/styles'));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.