3

我正在尝试在 Laravel 5 中创建自定义 Elixir 任务:

  1. 将 SVG 文件转换为网站图标。
  2. 优化创建的图标。
  3. 删除未优化的网站图标。

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');

});

它不起作用,我不知道接下来要尝试什么:

/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)
4

1 回答 1

0

错误消息似乎很清楚 - 它找不到您要优化的网站图标。

于 2015-06-28T18:16:40.837 回答