How to use gulp-imagemin - 10 common examples

To help you get started, we’ve selected a few gulp-imagemin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsebastien / midnightLightV2 / gulp / tasks / images.js View on Github external
gulp.task('images', 'Optimize images', () =>{
	return utils.plumbedSrc(
			config.images.src
	)

	// Display the files in the stream
	//.pipe(debug({title: 'Stream contents:', minimal: true}))

	// Minify and cache
	.pipe(cache(imageMin({
		progressive: true,
		interlaced: true
	})))

	// Output files
	.pipe(gulp.dest(config.images.dest))

	// Task result
	.pipe(size({
		title: 'images'
	}));
});
github baonguyenyam / canhcam-cab / core / k-task / task / gulp / imagemin.js View on Github external
gulp.task('imagemin', () => {

        return gulp.src(path.join(target, '**/.{gif,png,jpg,jpeg,bmp,svg}'))
            .pipe(imagemin([
                imagemin.gifsicle({ interlaced: true }),
                imagemin.jpegtran({ progressive: true }),
                imagemin.optipng({ optimizationLevel: 7 }),
                imagemin.svgo({ plugins: [{ removeViewBox: true }] })
            ], {
                verbose: true
            }))
            // .pipe(plugins.changed(dest))
            .pipe(gulp.dest(dest));

    });
github imweb / generator-imweb-wxapp / generators / app / templates / gulpfile.js View on Github external
function img() {
  return src(`${srcDir}/**/*.{png,jpe?g,gif,svg}`)
    .pipe(
      cache(
        imagemin([
          imagemin.gifsicle({ interlaced: true }),
          imagemin.jpegtran({ progressive: true }),
          imagemin.optipng({ optimizationLevel: 4 }),
          imagemin.svgo({
            plugins: [
              { removeDimensions: true }, // 如果有 viewbox 则不需要 width 和 height
            ],
          }),
        ])
      )
    )
    .pipe(
      dest(file => {
        return file.base; // 压缩到原目录
      })
    );
}
github jbrodriguez / hugulp / gulp / build.js View on Github external
gulp.task('images', function() {
  return gulp
    .src(path.join(config.build.source, config.path.images, '**', '*.*')) // i.e.: public/images/**/*.*
    .pipe(
      imagemin([
        imagemin.gifsicle(config.gifsicle),
        imagemin.jpegtran(config.jpegtran),
        imagemin.optipng(config.optipng),
        imagemin.svgo(config.svgo)
      ])
    )
    .pipe(gulp.dest(path.join(config.build.target, config.path.images))) // i.e.: public/images
})
github rackerlabs / table-builder / gulpfile.js View on Github external
const imgTask = function buildImages() {
  return gulp.src('src/images/**/*')
   .pipe(imagemin([
     imagemin.optipng({ optimizationLevel: 5 }),
   ]))
   .pipe(gulp.dest('dist/images'))
   .on('end', () => {
     console.log('Successfully compressed images');
   });
};
github XGHeaven / cnode-angular-material / gulpfile.es6.js View on Github external
gulp.task('image', () => {
    return gulp.src('./src/image/**/*.*')
    .pipe(imagemin({
        progressive: true
    }))
    .pipe(gulp.dest(DIST + '/image'))
})
github vwxyutarooo / gulp-web-starter / tools / gulp / image.js View on Github external
gulp.task('imagemin', () => {
  gulp.src(paths.destImg + 'page/**/*.*')
    .pipe(imagemin({ optimizationLevel: 3 }))
    .pipe(gulp.dest(paths.destImg + 'page/'));
});
github art-software / art-core / packages / art-webpack-miniprogram / src / compiler / compileImage.ts View on Github external
return new Promise((resolve) => {
    vfs.src(path, getSrcOptions())
      .pipe(plumber(handleErros))
      .pipe(gulpif(
          isProd(),
          gulpImagemin()
        )
      )
      .pipe(getDest(vfs))
      .on('end', resolve);
  });
};
github andrew--r / frontendbookshelf / gulp / tasks / images.js View on Github external
gulp.task('images:site', () => {
	return gulp
		.src(`${PATHS.source.images.site}/**/*`)
		.pipe(imagemin())
		.pipe(gulp.dest(PATHS.build.images));
});
github jimmylee / dough / gulp / tasks / minify-and-copy-images-to-build-directory.js View on Github external
gulp.task('minify-and-copy-images-to-build-directory', () => {
  return gulp.src(config.images.src)
    .pipe(gulpif(global.isProduction, imagemin()))
    .pipe(gulp.dest(config.images.dest))
    .pipe(gulpif(browserSync.active, browserSync.reload({ stream: true, once: true })));
});

gulp-imagemin

Minify PNG, JPEG, GIF and SVG images

MIT
Latest version published 6 months ago

Package Health Score

66 / 100
Full package analysis