mixtur / webpack-spritesmith

Webpack plugin that converts set of images into a spritesheet and SASS/LESS/Stylus mixins
499 stars 56 forks source link

remove '.png' at the end of generated sprite name. #72

Closed SaniHaque closed 5 years ago

SaniHaque commented 6 years ago

is there a way to remove that extension name on every image name. it's really annoying. Otherwise great job. Thank you.

SaniHaque commented 6 years ago
 generateSpriteName: function (imageLoc) {
    let image = imageLoc.split("\\");
    let name = image[image.length - 1].replace(".png", "");
    return name;
 },

dosn;t work. is it because of format: 'json_texture', if it is how to solve this.

mixtur commented 6 years ago

So there is "png" in sprite names? Like $some-icon-png?

mixtur commented 6 years ago

what is your target.css?

SaniHaque commented 6 years ago

my target is not css, it's json. and i'm using format: 'json_texture' option.

mixtur commented 6 years ago

Your problem is here https://github.com/twolfson/spritesheet-templates/blob/master/lib/templates/json_texture.template.js#L21-L27 I am trying to match gulp.spritesmith behaviour. gulp.spritesmith does not defines sprite.frame_name, and it puts original file name in sprite.source_image. So am I.

generateSpriteName doesn't work here because it only changes sprite.name. And related code is never reached in this template (at least with versions of webpack-spritesmith >=0.5.0).

So you can do one of two things: a) write custom template that names sprites in some other way. b) rollback to 0.4.1, It does not defines sprite.source_image, so generateSpriteName would work as you expect (though it may not be needed).

SaniHaque commented 6 years ago

too bad then.☹ thanks anyway.👍