drdk / grunt-dr-svg-sprites

Grunt plugin to create SVG sprites with PNG fallbacks at needed sizes
113 stars 19 forks source link

attach new icons on the last position in the sprite #38

Closed philipisik closed 9 years ago

philipisik commented 9 years ago

Hi,

is it possible to attach new svg files always on the last position in the sprite?

Cheers Philip

phloe commented 9 years ago

If you name your files in running order - yes ;)

If you have: 01-triangle.svg, 02-circle.svg. Then later adding a new file (03-square.svg) - you would get what you want. (You can rewrite classnames/selectors via options.selector)

philipisik commented 9 years ago

Thank you for your reply. I solved the problem your way. This is my options selector:

selector: function (filename, tokens) {
    filename = filename.replace(/^(icon-)(\d+)-/, "$1");
    // console.log(filename);
    var parts = [filename];
    if (tokens.prefix) {
        parts.unshift(tokens.prefix);
    }
    if (tokens.size) {
        parts.push(tokens.size);
    }
    return "." + parts.join("-");
},