是否可以使用诸如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'));
});