{"id":23968885,"url":"https://github.com/heshanera/svg-asset-loader","last_synced_at":"2026-02-25T09:34:07.042Z","repository":{"id":243364481,"uuid":"810895314","full_name":"heshanera/svg-asset-loader","owner":"heshanera","description":"Webpack loader for processing SVG files. Loader options allows embedding SVGs into the HTML, spritesheet injection, or spritesheet extraction for linking.","archived":false,"fork":false,"pushed_at":"2024-12-17T15:27:04.000Z","size":544,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T03:28:52.474Z","etag":null,"topics":["inline-svg","loader","spritesheet","svg","svg-extract","svg-processor","svg-sprites","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/svg-asset-loader","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/heshanera.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-06-05T14:51:53.000Z","updated_at":"2024-12-17T15:27:06.000Z","dependencies_parsed_at":"2024-06-08T11:24:46.619Z","dependency_job_id":"cda601e2-ccdf-4289-a110-5a65177c22ee","html_url":"https://github.com/heshanera/svg-asset-loader","commit_stats":null,"previous_names":["heshanera/svg-asset-loader"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/heshanera/svg-asset-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heshanera%2Fsvg-asset-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heshanera%2Fsvg-asset-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heshanera%2Fsvg-asset-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heshanera%2Fsvg-asset-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heshanera","download_url":"https://codeload.github.com/heshanera/svg-asset-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heshanera%2Fsvg-asset-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29816101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["inline-svg","loader","spritesheet","svg","svg-extract","svg-processor","svg-sprites","webpack","webpack-loader"],"created_at":"2025-01-07T00:55:26.013Z","updated_at":"2026-02-25T09:34:07.012Z","avatar_url":"https://github.com/heshanera.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svg-asset-loader\nWebpack loader for processing SVG files. Loader options allows 3 options: embedding SVGs directly into the HTML, combining SVGs into a single spritesheet injected into the HTML, or extracting SVGs into an external sprite file for linking.\n\n[![Test Build Publish](https://github.com/heshanera/svg-asset-loader/actions/workflows/publish.yml/badge.svg)](https://github.com/heshanera/svg-asset-loader/actions)\u0026nbsp;\n[![Node](https://img.shields.io/badge/NodeJS-v20.10.0-%233C873A)](https://nodejs.org/dist/v20.14.0/docs/api/)\u0026nbsp;\n[![NPM](https://img.shields.io/badge/NPM-v10.2.3-%23CC3534)](https://www.npmjs.com/package/svg-asset-loader?activeTab=readme)\u0026nbsp;\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue)](https://github.com/heshanera/svg-asset-loader/blob/master/LICENSE)\u0026nbsp;\n[![Minzip](https://img.shields.io/bundlephobia/minzip/svg-asset-loader)](https://bundlephobia.com/package/svg-asset-loader)\u0026nbsp;\n\n## Installation\n```bash\nnpm i svg-asset-loader\n```\n\n## Usage\n\n### Spritesheet injection [:link:](https://github.com/heshanera/svg-asset-loader/tree/master/examples/injectSVGs)\n```js\n// webpack.config.js\n\nconst config = {\n  ...\n  module: {\n    rules: [\n      {\n        test: /\\.svg$/,\n        loader: 'svg-asset-loader',\n      },\n    ],\n  },\n  ...\n};\n\nexport default config;\n```\n```js\n// index.js\n\nimport icon from '../../assets/stop-watch.svg';\nimport icon2 from '../../assets/coconut-tree.svg';\n\n...\n\u003cdiv\u003e\n  \u003csvg viewBox=\"${icon.viewBox}\"\u003e\n    \u003cuse href=\"#${icon.id}\"\u003e\u003c/use\u003e\n  \u003c/svg\u003e\n  \u003csvg viewBox=\"${icon2.viewBox}\"\u003e\n    \u003cuse href=\"#${icon2.id}\"\u003e\u003c/use\u003e\n  \u003c/svg\u003e\n\u003c/div\u003e\n...\n```\n\n### Inline [:link:](https://github.com/heshanera/svg-asset-loader/tree/master/examples/inlineSVGs)\n```js\n// webpack.config.js\n\nconst config = {\n  ...\n  module: {\n    rules: [\n      {\n        test: /\\.svg$/,\n        loader: 'svg-asset-loader',\n        options: {\n          strategy: 'inline',\n        },\n      },\n    ],\n  },\n  ...\n};\n\nexport default config;\n```\n```js\n// index.js\n\nimport icon from '../../assets/stop-watch.svg';\nimport icon2 from '../../assets/coconut-tree.svg';\n\n...\n\u003cdiv\u003e\n  \u003cimg src=${icon} height=\"100px\" width=\"100px\" /\u003e\n  \u003cimg src=${icon2} height=\"100px\" width=\"100px\" /\u003e\n\u003c/div\u003e\n...\n```\n\n\n### Extraction and linking [:link:](https://github.com/heshanera/svg-asset-loader/tree/master/examples/extractSVGs)\n```js\n// webpack.config.js\n\nconst config = {\n  ...\n  module: {\n    rules: [\n      {\n        test: /\\.svg$/,\n        loader: 'svg-asset-loader',\n        options: {\n          strategy: 'extract',\n          outFile: './public/spritesheet.svg',\n          prefix: './spritesheet.svg',\n        },\n      },\n    ],\n  },\n  ...\n};\n\nexport default config;\n```\n```js\n// index.js\n\nimport icon from '../../assets/stop-watch.svg';\nimport icon2 from '../../assets/coconut-tree.svg';\n\n...\n\u003cdiv\u003e\n  \u003csvg viewBox=\"${icon.viewBox}\"\u003e\n    \u003cuse href=${icon.href}\u003e\u003c/use\u003e\n  \u003c/svg\u003e\n  \u003csvg viewBox=\"${icon2.viewBox}\"\u003e\n    \u003cuse href=${icon2.href}\u003e\u003c/use\u003e\n  \u003c/svg\u003e\n\u003c/div\u003e\n...\n```\n\n## Loader Options\n\n| Property   | Default | Description |\n| ---------- | ------------ | -------- |\n| strategy   | `inject`     | SVG loading strategy \u003cbr /\u003e Available strategies: `inject`, `extract`, `inline`  |\n| outFile    | `sprite.svg` | File name for the generated svg spritesheet \u003cbr /\u003e To be used with the `extract` strategy    |\n| prefix     | `sprite.svg` | File path to access the generated spritesheet \u003cbr /\u003e To be used with the `extract` strategy \u003cbr /\u003e  href: `{prefix}#{id}`   |\n\n## Running Examples Locally\n\n```bash\n# Build the loader\nnpm run build\n\n# Go to the example directory\ncd examples/inlineSVGs/\n\n# Start the server\nnpm run start\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheshanera%2Fsvg-asset-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheshanera%2Fsvg-asset-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheshanera%2Fsvg-asset-loader/lists"}