I'm trying to create a custom Elixir task in Laravel 5:
- Convert a SVG file to favicons.
- Optimize the created favicons.
- Delete the unoptimized favicons.
var gulp = require('gulp');
var runSequence = require('run-sequence');
var favicons = require('favicons');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var clean = require('gulp-clean');
var elixir = require("laravel-elixir");
elixir.extend('favicons', function(input, output, temporary) {
gulp.task('svgToFavicons', function() {
return favicons({
source: input,
dest: temporary,
android: true,
apple: true,
coast: true,
favicons: true,
firefox: true,
opengraph: false,
windows: true,
html: null,
background: '#1d1d1d',
tileBlackWhite: false,
manifest: null,
trueColor: false,
url: null,
logging: false,
callback: null
});
});
gulp.task('optimizeFavicons', ['svgToFavicons'], function() {
return gulp.src(temporary + '/*')
.pipe(imagemin({
progressive: true,
optimizationLevel: 1,
use: [pngquant()]
}))
.pipe(gulp.dest(output));
});
gulp.task('deleteUnoptimizedFavicons', ['svgToFavicons', 'optimizeFavicons'], function() {
return gulp.src(temporary, {read: false})
.pipe(clean());
});
gulp.task('createFavicons', function(callback) {
runSequence(
'svgToFavicons',
'optimizeFavicons',
'deleteUnoptimizedFavicons',
callback);
});
this.registerWatcher('createFavicons', input);
return this.queueTask('createFavicons');
});
It doesn't work and I have no idea what to try next:
/path/to/project/node_modules/favicons/index.js:77
throw error;
^
Error: Command failed: convert: unable to open image `storage/temporary/images/favicons/16x16.png': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: unable to open file `storage/temporary/images/favicons/16x16.png' @ error/png.c/ReadPNGImage/4050.
convert: unable to open image `storage/temporary/images/favicons/32x32.png': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: unable to open file `storage/temporary/images/favicons/32x32.png' @ error/png.c/ReadPNGImage/4050.
convert: unable to open image `storage/temporary/images/favicons/48x48.png': No such file or directory @ error/blob.c/OpenBlob/2709.
convert: unable to open file `storage/temporary/images/favicons/48x48.png' @ error/png.c/ReadPNGImage/4050.
convert: no images defined `storage/temporary/images/favicons/favicon.ico' @ error/convert.c/ConvertImageCommand/3187.
at ChildProcess.exithandler (child_process.js:648:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket.<anonymous> (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
The error message seems pretty clear - it can't find the favicons you want to optimize.