Skip to content

Instantly share code, notes, and snippets.

@shaneparsons
Last active December 4, 2015 18:54
Show Gist options
  • Save shaneparsons/7a9563f377754b3a07e3 to your computer and use it in GitHub Desktop.
Save shaneparsons/7a9563f377754b3a07e3 to your computer and use it in GitHub Desktop.
laravel-elixir-imagemin - minify images
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
var changed = require('gulp-changed');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var Task = Elixir.Task;
Elixir.extend('images', function (src, output) {
new Task('images', function () {
return gulp.src(src)
.pipe(changed(output))
.pipe(imagemin({
progressive: true,
svgoPlugins: [
{cleanupIDs: false},
{cleanupNumericValues: false},
{convertShapeToPath: false},
{mergePaths: false},
{removeUnknownsAndDefaults: false},
{removeViewBox: false},
],
use: [pngquant()]
}))
.pipe(gulp.dest(output))
.pipe(new Elixir.Notification('Images Minified!'));
})
.watch(src);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment