Вставить svg в код GatsbyJS

  • Установить плагин

npm install --save gatsby-plugin-react-svg
  • Вставить In your gatsby-config.js

plugins: [
  {
    resolve: "gatsby-plugin-react-svg",
    options: {
      rule: {
        include: /assets/ // See below to configure properly
      }
    }
  }
];
  • Вызвать компонент из кода

import Icon from "./path/assets/icon.svg";

// ...

<Icon />;

Last updated