jacobmischka / gatsby-plugin-react-svg

Adds svg-react-loader to gatsby webpack config
https://www.npmjs.com/package/gatsby-plugin-react-svg
MIT License
70 stars 21 forks source link

Issue SVG on Windows #14

Closed jeremybarbet closed 5 years ago

jeremybarbet commented 5 years ago

Hey!

We've been using your plugin on our gatsby-starter and it all works fine on OSX, until recently when an user try to run the starter under windows he got an issue:

image

I've been trying to debug and see what's wrong with the plugin but I can't really say,

Thanks in advance,

jacobmischka commented 5 years ago

Looks like those SVGs you're trying to render aren't being included by the plugin, the import is resulting in the data string which is what it does by default. Please ensure your include option setting is correct.

jeremybarbet commented 5 years ago

Okay great, you pointed me to the right direction:

include: /assets\/svg/,

was just working for OSX, but not on Windows, I replaced it with:

include: include: path.resolve(__dirname, 'src/assets/svg'),

and now it works on both OSX and Windows,

Thanks

jacobmischka commented 5 years ago

Glad you got it figured out!

Guessing it was a problem with path separators, the \/ wasn't matching on Windows because paths use backslashes instead. I suppose /assets(\/|\\)svg/ would work as well, though the absolute path instead of the regex is probably a better call.