twolfson / gulp.spritesmith

Convert a set of images into a spritesheet and CSS variables via gulp
The Unlicense
1.07k stars 81 forks source link

imgName is not appended to imgPath if imgPath is set (sass) #35

Closed bserem closed 9 years ago

bserem commented 9 years ago

Been trying spritesmith today, it works and is brilliant. However, I think I found an issue. Please ignore the line numbers in the code blocks below :)

This:

138   var spriteData = gulp.src(config.sprites)                                                                                              
139     .pipe(spritesmith({                                                                                                                  
140       imgName: 'sprites.png',                                                                                                            
141       cssName: '_sprites.scss',                                                                                                          
142       algorithm: 'top-down',                                                                                                             
143       padding: 2,                                                                                                                        
144     }));  

Works and produces this output: $arrow-navigation-left: (0px, 56px, 0px, -56px, 46px, 95px, 337px, 496px, 'sprites.png', 'arrow_navigation_left', );

Now, setting imgPath:

138   var spriteData = gulp.src(config.sprites)                                                                                              
139     .pipe(spritesmith({                                                                                                                  
140       imgPath: '../assets/images',                                                                                                       
141       imgName: 'sprites.png',                                                                                                            
142       cssName: '_sprites.scss',                                                                                                          
143       algorithm: 'top-down',                                                                                                             
144       padding: 2,                                                                                                                        
145     }));  

I'm getting this (notice that there is no filename in the path): $arrow-navigation-left: (0px, 56px, 0px, -56px, 46px, 95px, 337px, 496px, '../assets/images', 'arrow_navigation_left', );

I need to add the filename in the path to get it working:

137 gulp.task('sprites', function () {                                                                                                       
138   var spriteData = gulp.src(config.sprites)                                                                                              
139     .pipe(spritesmith({                                                                                                                  
140       imgPath: '../assets/images/sprites.png',                                                                                           
141       imgName: 'sprites.png',                                                                                                            
142       cssName: '_sprites.scss',                                                                                                          
143       algorithm: 'top-down',                                                                                                             
144       padding: 2,                                                                                                                        
145     }));

And now I have the final sass file which points to the sprite file: $arrow-navigation-left: (0px, 56px, 0px, -56px, 46px, 95px, 337px, 496px, '../assets/images/sprites.png', 'arrow_navigation_left', );

I do not know if this is intended, I thought it would be good to mention it.

twolfson commented 9 years ago

That is working as intended. We use the direct version of imgPath in the CSS variables to avoid any potential edge cases that occur by adjusting data.

bserem commented 9 years ago

Thanks ;)