Requires grunt-spritesmith which generates a spritesheet from a bunch of images.
This gist passes a custom template for spritesmith to generate the SCSS file.
Gruntfile.js
sprite: {
src: "images/*.png",
dest: "sprites.png",
destCss: "_sprites.scss",
padding: 2, // Due to rounding, needs some space between images
cssTemplate: "sprites.scss.handlebars"
}
index.html
<div class="sprite-github"></div>
If either
$total-width
equals{{width}}
or$total-height
equals{{height}}
you get a division by 0 and an error. This can happen if the sprites-file is only one image wide. To remedy this you need to change the code into