ben-eb / gulp-svgmin

Minify SVG files with gulp.
MIT License
340 stars 34 forks source link

Log minified files #5

Closed markgoodyear closed 10 years ago

markgoodyear commented 10 years ago

I find it handy to see what files have been minified, especially when using a caching plugin.

ben-eb commented 10 years ago

See #4. Although it might be appropriate to add a section in the readme for use cases such as adding a filesize reporter into the build chain.

markgoodyear commented 10 years ago

I could use that, although I'm not after logging the file-size. This is to just log the filename of changed files—similar to gulp-imagemin. No worries if you'd prefer to let gulp-bytediff handle it. :)

ben-eb commented 10 years ago

OK, that's fine. If you want to log the file paths that were changed you could always use something like the following:

var gulp  = require('gulp');
var gutil = require('gulp-util');
var svgmin = require('gulp-svgmin');
var map = require('map-stream');

gulp.task('icons', function() {
  return gulp.src(['./icons/*.svg'])
    .pipe(map(function(file, cb) {
        gutil.log(file.path);
        cb(null, file);
    }))
    .pipe(svgmin())
    .pipe(gulp.dest('out'));
});

Personally I like the style of gulp modules just doing one thing, in this case I feel that other plugins should handle things like reporting the file paths picked up by a glob. That way you have a generic solution that can be implemented in your build, regardless of whether the plugin author chose to add one into their plugin or not.

markgoodyear commented 10 years ago

Thanks for the example Ben, I was having trouble figuring something like that out.

ben-eb commented 10 years ago

You're welcome. :-)