{"id":27733733,"url":"https://github.com/pixel-point/gatsby-plugin-svgr-svgo","last_synced_at":"2025-04-28T13:00:15.006Z","repository":{"id":38433016,"uuid":"232535743","full_name":"pixel-point/gatsby-plugin-svgr-svgo","owner":"pixel-point","description":"Gatsby plugin for SVG usage with react, svgo support","archived":false,"fork":false,"pushed_at":"2023-03-04T05:37:17.000Z","size":4563,"stargazers_count":16,"open_issues_count":15,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-28T13:00:06.873Z","etag":null,"topics":["gatsby","gatsby-plugin","react","react-svg","svg","svgo","svgr"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixel-point.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-08T10:15:35.000Z","updated_at":"2024-02-24T21:05:41.000Z","dependencies_parsed_at":"2024-06-21T13:13:16.480Z","dependency_job_id":"6c6cce9f-fc1f-464b-aca7-c0e4ff80e3ba","html_url":"https://github.com/pixel-point/gatsby-plugin-svgr-svgo","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":"0.14893617021276595","last_synced_commit":"047446f13c2e719b6904be70eb5c9965e63fd941"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixel-point%2Fgatsby-plugin-svgr-svgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixel-point%2Fgatsby-plugin-svgr-svgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixel-point%2Fgatsby-plugin-svgr-svgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixel-point%2Fgatsby-plugin-svgr-svgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixel-point","download_url":"https://codeload.github.com/pixel-point/gatsby-plugin-svgr-svgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251319598,"owners_count":21570426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gatsby","gatsby-plugin","react","react-svg","svg","svgo","svgr"],"created_at":"2025-04-28T13:00:14.080Z","updated_at":"2025-04-28T13:00:14.989Z","avatar_url":"https://github.com/pixel-point.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gatsby-plugin-svgr-svgo\r\n\r\nPlugin allows you to use SVGs as react components, configure SVGO(SVG optimization) settings and declare rules for SVG url loader with or without optimization.\r\n\r\n[![npm version](https://badge.fury.io/js/gatsby-plugin-svgr-svgo.svg)](https://badge.fury.io/js/gatsby-plugin-svgr-svgo)\r\n![Drone](https://img.shields.io/drone/build/pixel-point/gatsby-plugin-svgr-svgo?server=https%3A%2F%2Fdrone.pixelpoint.io)\r\n\r\n## Install\r\n\r\nFor Gatsby 3.0.0+ versions use\r\n\r\n```\r\nnpm install gatsby-plugin-svgr-svgo @svgr/webpack --save\r\n```\r\n\r\nFor Gatsby 2.3.0+ versions use\r\n\r\n```\r\nnpm install gatsby-plugin-svgr-svgo@1.1.0 @svgr/webpack --save\r\n```\r\n\r\nFor older versions\r\n\r\n```\r\nnpm install gatsby-plugin-svgr-svgo@v1.0.12 @svgr/webpack --save\r\n```\r\n\r\n## Setup\r\n\r\n### Default configuration\r\n\r\nAdd to your gatsby-config.js\r\n\r\n```js\r\nplugins: [`gatsby-plugin-svgr-svgo`];\r\n```\r\n\r\nBy default there are two rules will be added:\r\n\r\n1. SVG as a react component(inline svg), SVGO enabled for all SVGs that have .inline postfix. Example: `cat.inline.svg`\r\n\r\n```js\r\nimport React from \"react\";\r\nimport CatInlineSvg from \"../images/cat.inline.svg\";\r\n\r\nconst IndexPage = () =\u003e (\r\n  \u003cdiv\u003e\r\n    \u003cCatInlineSvg /\u003e\r\n  \u003c/div\u003e\r\n);\r\n\r\nexport default IndexPage;\r\n```\r\n\r\n2. SVG as a file that available by url, SVGO enabled for all svgs that have `.svg`. Example: `cat.svg`.\r\n\r\n```js\r\nimport React from \"react\";\r\nimport CatSvg from \"../images/cat.svg\";\r\n\r\nconst IndexPage = () =\u003e (\r\n  \u003cdiv\u003e\r\n    \u003cimg src={CatSvg} /\u003e\r\n  \u003c/div\u003e\r\n);\r\n\r\nexport default IndexPage;\r\n```\r\n\r\n### Advanced configuration\r\n\r\n```js\r\nplugins: [\r\n  {\r\n    resolve: \"gatsby-plugin-svgr-svgo\",\r\n    options: {\r\n      inlineSvgOptions: [\r\n        {\r\n          test: /\\.inline.svg$/,\r\n          svgoConfig: {\r\n            plugins: [\r\n              {\r\n                name: \"preset-default\",\r\n                params: {\r\n                  overrides: [{ name: \"removeViewBox\", active: false }],\r\n                },\r\n              },\r\n              \"prefixIds\",\r\n            ],\r\n          },\r\n        },\r\n      ],\r\n      urlSvgOptions: [\r\n        {\r\n          test: /\\.svg$/,\r\n          svgoConfig: {\r\n            plugins: [{ name: \"removeViewBox\", active: false }],\r\n          },\r\n        },\r\n      ],\r\n    },\r\n  },\r\n];\r\n```\r\n\r\nYou can declare various rules based on loader that should be used under `inlineSvgOptions` and `urlSvgOptions`.\r\n\r\n`test` - pattern that will be used to match file name\r\n\r\n`svgoConfig` - accepts plugins list with settings, list of available plugins(options) you can find [here](https://github.com/svg/svgo#what-it-can-do)\r\n\r\n`svgo` - disables SVGO if set in `false`\r\n\r\n### SVGO disabled example\r\n\r\n```js\r\nplugins: [\r\n  {\r\n    resolve: \"gatsby-plugin-svgr-svgo\",\r\n    options: {\r\n      urlSvgOptions: [\r\n        {\r\n          test: /\\.svg$/,\r\n          svgo: false,\r\n        },\r\n      ],\r\n    },\r\n  },\r\n];\r\n```\r\n\r\n### Set URL loader fallback limit\r\n\r\nBy default webpack `url-loader` has a fallback to `file-loader` that converts the file from the original extension to base64. Plugins set default as 512 bytes. So if you want to set the limit from which it should be loaded directly from url instead of base64 loading just use limit option within `urlLoaderOptions`.\r\n\r\nLimits you set in bytes. Read about more options [there](https://webpack.js.org/loaders/url-loader/)\r\n\r\n```js\r\nurlSvgOptions: [\r\n  {\r\n    test: /\\.svg$/,\r\n    svgoConfig: {\r\n      plugins: [{ name: \"removeViewBox\", active: false }],\r\n    },\r\n    urlLoaderOptions: {\r\n      limit: 512,\r\n    },\r\n  },\r\n];\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixel-point%2Fgatsby-plugin-svgr-svgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixel-point%2Fgatsby-plugin-svgr-svgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixel-point%2Fgatsby-plugin-svgr-svgo/lists"}