mixtur / webpack-spritesmith

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

Return from generateSpriteNames not being used #67

Closed colmandesilva closed 6 years ago

colmandesilva commented 6 years ago
new SpritesmithPlugin({
            src: {
                cwd: path.resolve(__dirname, 'src/assets/spritesheets/'),
                glob: '**/*/*.png'
            },
            target: {
                image: path.resolve(__dirname, 'dist/assets/spritesheets/sprite.png'),
                css: [
                    [path.resolve(__dirname, 'dist/assets/spritesheets/sprite.json'), {
                        format: 'json_texture'
                    }]
                ]
            },
            apiOptions: {
                cssImageRef: "sprite.png",
                generateSpriteName: fullPathToSourceFile => {
                    const {name} = path.parse(fullPathToSourceFile);
                    return `sprite_${name}`;
                }
            }
        }),

I pulled part of the above from one of your previous answers. I have tried various different things, but I can't get generateSpriteName return to be used in the generated json file.

mixtur commented 6 years ago

I believe it is happening because of this https://github.com/twolfson/spritesheet-templates/blob/master/lib/templates/json_texture.template.js#L21-L27 and the fact that I just added source_image to mirror what gulp.spritesmith does. If that is the case, I think you have two options:

colmandesilva commented 6 years ago

Wonderful, rolling back to 0.4.1 did the trick. Much appreciated.