gulp-tinifier
v1.0.2
Published
A Gulp plugin for compress images with https://tinypng.com service
Downloads
1
Maintainers
Readme
gulp-tinifier
gulp-tinifier is a simple plugin which allows you to compress your images with https://tinypng.com/ service
Install
npm install gulp-tinifier --save
How it works
tinifier has a simple sintax accepts one only argument
var tinfier = require('gulp-tinifier');
...
var options = {
key:'YOUR_API_KEY',
verbose: true
}
gulp.src(imgToCompress)
.pipe(tinfier(options))
.pipe(gulp.dest("sprites-optimized", {cwd:distFolder}))
...
options
is an object and has the following proprieties
- key [string] your API key (you can grab it from https://tinypng.com/developers )
- verbose [boolean] true by default, it will show the progress in the console
Example
var tinfier = require('gulp-tinifier');
var config = require('./gulp.config.js');
var imgToCompress = [
config.dist + "assets/img/[email protected]",
config.dist + "assets/img/[email protected]"
];
var distFolder = config.dist + "assets/img/";
module.exports = function(gulp) {
return gulp.task("tinypng", function(done) {
gulp.src(imgToCompress)
.pipe(tinfier({
key:'YOUR_API_KEY',
verbose: true
}))
.pipe(gulp.dest("sprites-optimized", {cwd:distFolder}))
})
}