jacobmischka / gatsby-plugin-react-svg

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

Error on documentation in gatsby-config.js #49

Open erdemgonul opened 2 years ago

erdemgonul commented 2 years ago

Hi, I searched for a solution to this problem for hours but finally found it with my own efforts. While the usage pattern shown in the document in the config file is as below, giving the rule object and regex without using strings creates a problem.

1- remove rule and use include under options 2- put regex expressions between string tags

plugins: [
  {
    resolve: "gatsby-plugin-react-svg",
    options: {
      rule: {
        include: /assets/ // See below to configure properly
      }
    }
  }
];

should be

plugins: [
  {
    resolve: "gatsby-plugin-react-svg",
    options: {
        include: "/assets/"
    }
  }
];

Produced error on documentation way:

Failed to execute 'createElement' on 'Document': The tag name provided ('data:image/svg+xml;base64,PD94bWwgdmV ..... is not a valid name.

Thank you for that great plugin also! 🔥🔥

Edit: I can open a PR on that if you're ok