【发布时间】:2017-11-20 03:21:14
【问题描述】:
我正在使用以下 gulp 任务将所有 scss 处理为 CSS,将它们组合成一个缩小文件,并显示文件大小。但是,我想分别查看缩小后的 CSS 文件和地图文件的文件大小。以下不做这项工作。
gulp.task('styles', function () {
return gulp.src(config.css.src)
.pipe(glob())
.pipe(plumber({
errorHandler: function (error) {
notify.onError({
title: 'Processing all custom SCSS files to css',
subtitle: 'Failed!',
message: 'Error: <%= error.message %>',
sound: 'Frog '
})(error);
this.emit('end');
}}))
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(autoprefix(autoprefixerOptions))
.pipe(sourcemaps.write('./css'))
.pipe(gulp.dest(config.css.dest))
.pipe(size({
title: 'Total file size of custom css file and the map file associated with the css file: ',
showFiles: 'true',
showTotal: 'true',
prettySize: 'true'
}));
});
【问题讨论】:
-
收到了作者推特的回复。我引用“它显示通过管道的所有文件。如果您只想要一个文件,您可以使用
gulp-filter或gulp-if进行过滤。”。有谁知道我如何使用 gulp-if/gulp-filter 来获取一个文件的文件大小?