svg-sprite / grunt-svg-sprite

SVG sprites & stacks galore — Grunt plugin wrapping around svg-sprite that reads in a bunch of SVG files, optimizes them and creates SVG sprites and CSS resources in various flavours

Home Page:https://github.com/svg-sprite/svg-sprite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source path not being expanded properly

MojoJojo opened this issue · comments

It seems like the plugin is ignoring the cwd option passed in via gruntfile config. So give a config like below:

expand: true,
cwd: 'public/assets/dist/svgs/',
src: ['*/.svg'],
dest: 'public/assets/stylesheets/svg-sprites',

It seems like the plugin ignores the cwd option and starts processing all directories located in the base folder where gruntfile lies.

To verify my findings, I examined svg_sprites.js and it seems the following line (line no 66):

srcFiles = grunt.file.expand(src);

is cause of the problem. The line above ignores the cwd setting and just picks the files/patterns specified in the src parameter. In the example above for instance, it will basically scan all the directories and their sub-directories for svg files instead of limiting the search relative to 'public/assets/dist/svgs' folder.

Hi @thesanketsharma,

thanks for reporting this. I will have a look as soon as possible (which might turn out to be end of the month though). Thanks for your patience.

Cheers,
Joschi

My bad, I investigated this further and seems like I ended up installing the wrong grunt-svg-sprite module. There is another grunt-svg-sprites module (notice the 's' at the end) https://www.npmjs.com/package/grunt-svg-sprites which caused the confusion. I ended up installing the wrong npm module and was wondering why the config is not working.

Apologies for the trouble.

Glad you could figure this out! 👍