{"id":24507445,"url":"https://github.com/dnnsk/icon-sprite-generator","last_synced_at":"2025-03-15T09:15:13.286Z","repository":{"id":57270920,"uuid":"121847309","full_name":"dnnsk/icon-sprite-generator","owner":"dnnsk","description":"User-friendly SVG sprite generation","archived":false,"fork":false,"pushed_at":"2018-02-17T11:26:17.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T15:15:31.550Z","etag":null,"topics":["icons-generator","javascript","javascript-library","node-module","sprite","svg","svg-icons","svg-sprites"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dnnsk.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}},"created_at":"2018-02-17T10:49:16.000Z","updated_at":"2018-02-17T11:56:51.000Z","dependencies_parsed_at":"2022-09-06T21:52:51.186Z","dependency_job_id":null,"html_url":"https://github.com/dnnsk/icon-sprite-generator","commit_stats":null,"previous_names":["denis-kalinichenko/icon-sprite-generator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnnsk%2Ficon-sprite-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnnsk%2Ficon-sprite-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnnsk%2Ficon-sprite-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnnsk%2Ficon-sprite-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnnsk","download_url":"https://codeload.github.com/dnnsk/icon-sprite-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707367,"owners_count":20334618,"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":["icons-generator","javascript","javascript-library","node-module","sprite","svg","svg-icons","svg-sprites"],"created_at":"2025-01-21T23:50:44.406Z","updated_at":"2025-03-15T09:15:13.267Z","avatar_url":"https://github.com/dnnsk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# icon-sprite-generator\n\n\u003e User-friendly SVG sprite generation \n\n## Features\n\n- Promise API\n- Supports glob file matching (patterns based on [globby](https://github.com/sindresorhus/globby))\n- SVG cleaner built-in (removes unneeded attributes and tags)\n- Exports sprite on disk\n- Optional wrapping with JavaScript Loader (for browsers)\n\n## Install\n\n```\n$ npm install icon-sprite-generator --save\n```\n\n## Usage\n\n```javascript\nconst generator = require(\"icon-sprite-generator\");\n\n/* async/await */\n(async () =\u003e {\n    const sprite = await generator({\n        output: \"file.svg\",\n    });\n\n    console.log(sprite);\n})();\n\n/* Promises */\ngenerator({\n    output: \"file.svg\",\n}).then(sprite =\u003e {\n    console.log(sprite);\n});\n```\n\n## API\n\n### generator([options])\n\nReturns a Promise\u003cString\u003e of generated sprite.\n\n#### options\n\nType: `Object`\n\n##### input\n\nType: **[`globby pattern`](https://github.com/sindresorhus/globby)** (`string` `Array`)\u003cbr\u003e\n\nPath/s to your directory with icons (supports multiple patterns).\n\n##### output\n\nType: `string`\u003cbr\u003e\nDefault: `false`\n\nProvide output path and full filename (with extension) if you want to save it on disk.\n\n**Note:** Sprite will be wrapped with JS loader in case of extension equals \".js\".\n\n##### mode\n\nType: `string`\u003cbr\u003e\nDefault: `auto`\n\nYou can natively set mode to `jsLoader` if you want wrap sprite with JS Loader.\n\n## JS Loader\n\nThis additional option can wrap generated sprite with JavaScript code for browsers. \nIt inserts your sprite into DOM on `DOMContentLoaded` event. \n\nYou can include this file into `\u003chead\u003e`. \n\nThat's how it looks:\n\n```js\n(function() {\nvar ready = false;\nvar inject = function() {\nif (ready) { return; }\nready = true;\nvar svgHolder = document.createElement(\"div\");\nsvgHolder.className += \"svg-sprites-holder\";\nsvgHolder.innerHTML = \"\u003csvg xmlns=\\\"http://www.w3.org/2000/svg\\\" xmlns:xlink=\\\"http://www.w3.org/1999/xlink\\....\";\ndocument.body.appendChild(svgHolder);\n};\nif (document.readyState === \"complete\") { inject(); }\nelse { document.addEventListener(\"DOMContentLoaded\", inject); }\n})();\n```\n\n## Tests\nIn order to test this module - run `npm test`\n\n## License\nMIT © [Denis Kalinichenko](https://kalinichenko.me)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnnsk%2Ficon-sprite-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnnsk%2Ficon-sprite-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnnsk%2Ficon-sprite-generator/lists"}