{"id":17563444,"url":"https://github.com/fuxichen/rspack-plugin-svg","last_synced_at":"2025-03-07T15:32:29.397Z","repository":{"id":258905213,"uuid":"874761305","full_name":"fuxichen/rspack-plugin-svg","owner":"fuxichen","description":"svg rspack plugin","archived":false,"fork":false,"pushed_at":"2024-10-21T12:04:32.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T14:41:17.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fuxichen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-10-18T12:17:19.000Z","updated_at":"2025-01-12T18:27:53.000Z","dependencies_parsed_at":"2024-10-22T05:51:28.730Z","dependency_job_id":null,"html_url":"https://github.com/fuxichen/rspack-plugin-svg","commit_stats":null,"previous_names":["fuxichen/rspack-plugin-svg"],"tags_count":0,"template":false,"template_full_name":"rspack-contrib/rsbuild-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxichen%2Frspack-plugin-svg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxichen%2Frspack-plugin-svg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxichen%2Frspack-plugin-svg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuxichen%2Frspack-plugin-svg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuxichen","download_url":"https://codeload.github.com/fuxichen/rspack-plugin-svg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242415597,"owners_count":20124450,"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":[],"created_at":"2024-10-21T13:01:26.391Z","updated_at":"2025-03-07T15:32:29.095Z","avatar_url":"https://github.com/fuxichen.png","language":"TypeScript","readme":"# rsbuild-plugin-svg\n\nRsbuild plugin to load SVG files as Vue components, using SVGO for optimization.\n\nFork by [vite-svg-loader](https://github.com/jpkleemans/vite-svg-loader)\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/rsbuild-plugin-svg\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/rsbuild-plugin-svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/rsbuild-plugin-svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n  \u003ca href=\"https://npmcharts.com/compare/rsbuild-plugin-svg?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/rsbuild-plugin-example.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"downloads\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Usage\n\nInstall:\n\n```bash\nnpm add rsbuild-plugin-svg -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginSvg } from \"rsbuild-plugin-svg\";\n\nexport default {\n  plugins: [pluginSvg()],\n};\n```\n\n## Import params\n\n### URL\n\nSVGs can be imported as URLs using the `?url` suffix:\n\n```js\nimport iconUrl from './my-icon.svg?url'\n// 'data:image/svg+xml...'\n```\n\n### Raw\n\nSVGs can be imported as strings using the `?raw` suffix:\n\n```js\nimport iconRaw from './my-icon.svg?raw'\n// '\u003c?xml version=\"1.0\"?\u003e...'\n```\n\n### Component\n\nSVGs can be explicitly imported as Vue components using the `?component` suffix:\n\n```js\nimport IconComponent from './my-icon.svg?component'\n// \u003cIconComponent /\u003e\n```\n\n## Options\n\n### Default import config\n\nWhen no explicit params are provided SVGs will be imported as Vue components by default.\nThis can be changed using the `defaultImport` config setting,\nsuch that SVGs without params will be imported as URLs (or raw strings) instead.\n\n## defaultImport\n\n```js\nsvgLoader({\n  defaultImport: 'url' // or 'raw' default: 'component'\n})\n```\n\n### SVGO Configuration\n\n#### `vite.config.js`\n\n```js\nsvgLoader({\n  svgoConfig: {\n    multipass: true\n  }\n})\n```\n\n### Disable SVGO\n\n#### `vite.config.js`\n\n```js\nsvgLoader({\n  svgo: false\n})\n```\n\n### Skip SVGO for a single file\n\nSVGO can be explicitly disabled for one file by adding the `?skipsvgo` suffix:\n\n```js\nimport IconWithoutOptimizer from './my-icon.svg?skipsvgo'\n// \u003cIconWithoutOptimizer /\u003e\n```\n\n### Use with TypeScript\n\nIf you use the loader in a Typescript project, you'll need to reference the type definitions inside `vite-env.d.ts`:\n\n```ts\n/// \u003creference types=\"vite/client\" /\u003e\n/// \u003creference types=\"vite-svg-loader\" /\u003e\n```\n\n## License\n\n[MIT](./LICENSE).\n","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuxichen%2Frspack-plugin-svg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuxichen%2Frspack-plugin-svg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuxichen%2Frspack-plugin-svg/lists"}