gulp-responsive
gulp-responsive copied to clipboard
Can't filter with gulp-changed or gulp-newer
gulp-file.js
var gulp = require('gulp'),
responsive = require('gulp-responsive'),
$ = require('gulp-load-plugins')(),
sizes = [0.75, 0.5, 0.25, 0.2, 0.15, 0.1, 0.05];
gulp.task('misc', function () {
var dest = 'dist/misc';
return gulp.src(['originals/misc/*.png'])
.pipe($.newer(dest))
.pipe(gulp.dest(dest))
.pipe(responsive({
'*.png': sizes.map(function(size) {
return {
width: '' + (size * 100) + '%',
rename: {
suffix: size === 1 ? '' : ('@' + size + 'x'),
}
}
})
}))
.pipe(gulp.dest(dest));
});
When filtering with newer
or changed
, I get the following error:
[17:33:39] Starting 'misc'...
[17:33:39] gulp-responsive: Created 0 images (matched 0 of 0 images)
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: Available images do not match the following config:
- `*.png`
- `*.png`
- `*.png`
- `*.png`
- `*.png`
- `*.png`
- `*.png`
Any idea why it is not ignoring the filtered items?
Hi @thejase
I think you'll find useful my previous answer here https://github.com/mahnunchik/gulp-responsive/issues/18#issuecomment-154155133
Hey @mahnunchik, does gulp-cached only work with watch? If so, that means it'll run through all the files when gulp is first fired.
Hi @thejase
Yes, it'll process all files on first run.
1:many
relation between sources and destination files is complicated and not supported (on first run) by plugins I know.
You can copy original image to cache dir, then gulp-changed will work:
var img_resize = '_resize';
gulp.task('image', function () {
return gulp.src('static/image/**/*.{jpg,png}')
.pipe( plugins.changed( img_resize ) )
.pipe( gulp.dest( img_resize ) )
.pipe(plugins.responsive({
'**/*.{jpg,png}': [
...
See here: http://stackoverflow.com/a/35600699/277371