gulp-query-compress
Plugin for gulp-query
Compress your images in other directory
Uses imagemin,
pngquant for PNG and
pngquant for JPEG
This plugin provides automatic compress and copy.
npm install gulp-query gulp-query-compress
Example
Paste the code into your gulpfile.js
and configure it
let build = require('gulp-query')
, compress = require('gulp-query-compress')
;
build((query) => {
query.plugins([compress])
.compress('src/icons/*.png','images/')
.compress([
'src/icons/*.png',
{from:'src/bg/*',to: 'bg/'},
{from:'src/bg2/*',to: 'bg2/'}
], 'images/','admin')
.compress([
'src/icons/*.png',
{from:'src/bg/*',to: 'bg/'},
{from:'src/bg2/*',to: 'bg2/'}
], 'images/',{
png: {
quality: '60-70',
speed: 1
}
})
.compress({
name: 'any',
from: ['src/images/*.jpg'],
to: 'images/',
png: {
quality: '60-70',
speed: 1
},
jpeg: {
quality: 60,
}
})
;
});
And feel the freedom
gulp
gulp --production // For production (minification)
gulp watch // Watching change
gulp compress // Only for compress
gulp compress:admin // Only for task with name admin
...
Options
.compress({
name: "task_name",
from: 'src/images/*.jpg',
to: "images/",
png: {
quality: '60-70',
speed: 1
},
jpeg: {
quality: 60,
}
})