Question

I just installed grunt spritesheet onto my Windows system, and when I try to run the package, I get an error for this task: "grunt.spritesheet requires a sprites and sheet property".

The package looks loaded correctly, and runs with all of the other tasks with grunt. I have the Python2.7 and Cairo dependencies loaded as well.

In my main gruntfile (which already has require, jshint, and compass running fine), I added:

spritesheet: {
  // An array of filename / source images array pairs. The basename of the sprite file
  // is also prefixed to the CSS classes.
  sprites: {
    "images/icons/sprite.png": ['images/icons/*.png']
  },
  // The destination for the build stylesheet
  sheet: "scss/homepsprite.css"
}

So, the properties "sprites" and "sheet" are clearly there. Is there something else that I'm missing? The package is loading fine with the rest of the grunt modules... I have

 grunt.loadNpmTasks('grunt-spritesheet');

in my gruntfile as well as

 grunt.registerTask("default", ["jshint", "requirejs:dev", "compass:dev", "spritesheet"]);

Thanks for any feedback.

Was it helpful?

Solution

grunt-spritesheet is a multitask which @implicitly iterates over all of its named sub-properties@.

you could see that grunt is probably trying to run "sprites" and "sheet" as a task:

Running "spritesheet:sprites" (spritesheet) task

that means that the documentation is somewhat not so clear, and you need a "name" for your task which could basically be anything (i use generate here):

spritesheet: {
  generate: {
    // An array of filename / source images array pairs. The basename of the sprite file
    // is also prefixed to the CSS classes.
    sprites: {
      "images/icons/sprite.png": ['images/icons/*.png']
    },
    // The destination for the build stylesheet
    sheet: "scss/homepsprite.css"
  }
}

the output should now be:

Running "spritesheet:generate" (spritesheet) task
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top