vincentmac/gulp-fingerprint

Not working when CSS is already compressed

binarykitchen opened this issue · 2 comments

When I already have the whole CSS compressed into one very long line only, then this gulp plugin seems to replace the first occurrence only.

Try it yourself ...

Yes, that is by design. This plugin will only match one item per line. I would recommend using gulp-csso to minimize your css after running it through gulp-fingerprint. Here's an example of how I'm using it.

gulp.task('styles:dist', ['images:dist', 'images:lib:dist'], function () {
  var manifest = require('../../' + config.dist + '/image-manifest');
  _.assign(manifest, require('../../' + config.dist + '/image-lib-manifest'));  // combine manifest

  // See https://github.com/andrew/node-sass for more options
  return gulp.src('app/assets/stylesheets/app.scss')
    .pipe(sass({
      includePaths: [
        config.bower + '/foundation/scss',
        config.bower + '/compass-mixins/lib',
        'app/assets/stylesheets',
        'lib/assets/stylesheets'
      ],
      imagePath: '/assets',
    }))
    .pipe(fingerprint(manifest, {
      base: 'assets/',
      prefix: '/dist/images/',
      verbose: true
    }))
    .pipe(csso())  // minify css
    .pipe(gulp.dest(config.dist + '/styles'))
    .pipe(size());
});

Thanks, yeah, I figured that out myself recently too. Ticket closed!