gatsby-plugin-react-svg
gatsby-plugin-react-svg copied to clipboard
Include and exclude are not working correctly in all cases
I see that whatever gets passed as include or exclude to svg-react-loader will be added to url-loader too, just other way around, include --> exclude, exclude --> include.
That is not correct in all cases. For instance, all my images are held in the same directory. If I put that directory as include, it will be excluded for url-loader. That can be fixed by passing regex and checking for .svg extension. But, that is pointless, because svg-react-loader has test option for that extension, and passing regex with the same extension would be redundant, but it is important for url-loader to work. This gets even worse if I need to exclude node_modules (for any reason) because they will be included for url-loader.
I would like to be able to override those options. For instance, I would like to be able to pass urlLoaderInclude and urlLoaderExclude options and override default behavior as it is now.
Reasonable request. Though for your particular use case, if you don't include either include or exclude then svg-react-loader will just do all svgs and url-loader will do all other images. Is that not what you want anyway?
Yeah, sure, that is how it would work. In my case I'm using regex as a solution, just to be sure it will be applied only to images folder (I'm being extra safe, I have one more folder of images for marketing site).
I just reported this thinking forward. In some specific cases, it could be good to have control over what gets included/excluded for url-loader too. Even now we could just update webpack config after this plugin runs in our gatsby-node, it just seems easier to allow it with this lib, that's all.
Agreed, I just wanted to point out that option in the meantime until this gets implemented. I'll try to take a look soon!