twolfson / gulp.spritesmith

Convert a set of images into a spritesheet and CSS variables via gulp
The Unlicense
1.08k stars 81 forks source link

plugin don't regonized ´imgName´ #130

Closed simaodeveloper closed 7 years ago

simaodeveloper commented 7 years ago

my code:

gulp.task('sprite', function(){
    var spriteData = gulp.src('./src/images/sprite/*.png')
        .pipe(spritesmith('sprites.png', {
            imgName: 'sprite.png',
            cssName: 'sprite.styl'
        }));

    var imgStream = spriteData.img.pipe(buffer()).pipe(gulp.dest('./src/styles/utils'));
    var cssStream = spriteData.css.pipe(gulp.dest('./src/images'));

    return merge(imgStream, cssStream);
});

error in console:

[14:21:35] Starting 'sprite'...
[14:21:35] 'sprite' errored after 5.22 ms
[14:21:35] AssertionError [ERR_ASSERTION]: An `imgName` parameter was not provided to `gulp.spritesmith` (required)
    at gulpSpritesmith (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/node_modules/gulp.spritesmith/lib/gulp-spritesmith.js:81:3)
    at Gulp.<anonymous> (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/gulpfile.js:132:15)
    at module.exports (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/cin_dsilva/Documents/FDZ/fdz-webpage-boilerplate/node_modules/orchestrator/index.js:134:8)
    at /home/cin_dsilva/.nvm/versions/node/v8.4.0/lib/node_modules/gulp/bin/gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:611:11)
twolfson commented 7 years ago

There seems to be a string being passed as the first parameter. The first parameter should be an object. The following should work:

gulp.task('sprite', function(){
    var spriteData = gulp.src('./src/images/sprite/*.png')
        .pipe(spritesmith({
            imgName: 'sprite.png',
            cssName: 'sprite.styl'
        }));

    var imgStream = spriteData.img.pipe(buffer()).pipe(gulp.dest('./src/styles/utils'));
    var cssStream = spriteData.css.pipe(gulp.dest('./src/images'));

    return merge(imgStream, cssStream);
});