Last active
December 26, 2015 10:39
-
-
Save ahultgren/7138450 to your computer and use it in GitHub Desktop.
A template to generate a retina/high-res less spritesheet using grunt-spritesmith _without_ using both hi/low res images. Also it generates a bit less bloated rules than default. You might want to modify the template (eg classname and selector) depending on how you prefer to name stuff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
sprite: { | |
icons: { | |
src: 'img/icons/*.{png,jpg,gif}', | |
destImg: 'img/icons.png', | |
destCSS: 'less/general/icons.less', | |
algorithm: 'binary-tree', | |
cssTemplate: 'path/to/icon.template.mustache' | |
} | |
} | |
}); | |
// npm tasks | |
grunt.loadNpmTasks('grunt-spritesmith'); | |
// Default task. | |
grunt.registerTask('default', ['sprite']); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.icon { | |
background-image: url({{{items.0.escaped_image}}}); | |
background-size: {{items.0.px.total_width}}/2 auto; | |
{{#items}} | |
&.{{name}} { | |
background-position: {{px.offset_x}}/2 {{px.offset_y}}/2; | |
width: {{px.width}}/2; | |
height: {{px.height}}/2; | |
} | |
{{/items}} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment