{"id":22314363,"url":"https://github.com/undercloud/gulp-svg-inline-css","last_synced_at":"2025-03-26T02:46:00.974Z","repository":{"id":57150053,"uuid":"51659165","full_name":"undercloud/gulp-svg-inline-css","owner":"undercloud","description":"Colorize, styling SVG icons and converting into base64-encoded data URI strings","archived":false,"fork":false,"pushed_at":"2019-03-10T08:30:52.000Z","size":17,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T22:21:54.249Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/undercloud.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}},"created_at":"2016-02-13T18:27:42.000Z","updated_at":"2019-03-10T08:30:53.000Z","dependencies_parsed_at":"2022-09-03T18:01:18.408Z","dependency_job_id":null,"html_url":"https://github.com/undercloud/gulp-svg-inline-css","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undercloud%2Fgulp-svg-inline-css","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undercloud%2Fgulp-svg-inline-css/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undercloud%2Fgulp-svg-inline-css/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undercloud%2Fgulp-svg-inline-css/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/undercloud","download_url":"https://codeload.github.com/undercloud/gulp-svg-inline-css/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245579582,"owners_count":20638676,"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-12-03T22:09:45.858Z","updated_at":"2025-03-26T02:46:00.953Z","avatar_url":"https://github.com/undercloud.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-svg-inline-css\n\nColorize, styling SVG icons and converting into base64-encoded data URI strings\n\n## Install\n```npm install gulp-svg-inline-css```\n\n## Basic usage\n```js\nvar gulp = require('gulp'),\n    concat = require('gulp-concat'),\n    svg = require('gulp-svg-inline-css');\n\ngulp.task('style-svg', function() {\n  gulp.src('/path/to/*.svg')\n    .pipe(svg({\n      style: {\n        fill: '#E08283'\n      }\n    }))\n    .pipe(concat('sprites.css'))\n    .pipe(gulp.dest('styles/'));\n})\n```\n\n## Styling\nJust add ```key: value``` pairs like this\n```js\n...\n.pipe(svg({\n  style: {\n    fill: '#E08283',\n    stroke: '#674172',\n    strokeWidth: 1\n  }\n}))\n...\n```\nAll available style options you can find at https://www.w3.org/TR/SVG/painting.html\n\n\\*```camelCase``` keys will be transformed into ```dash-splitted```\u003cbr\u003e\n\\** inline style will be added for all elements in this list  ```path,rect,circle,ellipse,line,polyline,polygon,g,text```\n\n## Class names\nBy default defined this mask ```.icon.%s``` where ```%s``` is file name without extension.\nYou can define your own rules for building class name's, just add ```className``` key into build options: \n```js\n...\n.pipe(svg({\n  //bem like style\n  className: '.icon.icon--%s:hover',\n  style: {...}\n}))\n...\n```\nor use callback\n```js\n.pipe(svg({\n  className: function(fileName) {\n    return '.' + fileName.replace(/[^A-Za-z0-9_-]/g, '-').toLowerCase();\n  },\n  style: {...}\n}))\n```\n\n## Optimize SVG\nFor optimizing and compress use ```gulp-svgmin```  https://www.npmjs.com/package/gulp-svgmin\n```js\nvar gulp = require('gulp'),\n    concat = require('gulp-concat'),\n    svgmin = require('gulp-svgmin'),\n    svg = require('gulp-svg-inline-css');\n\ngulp.task('style-svg', function() {\n  gulp.src('/path/to/*.svg')\n    .pipe(svgmin())\n    .pipe(svg({\n      style: {\n        fill: '#E08283'\n      }\n    }))\n    .pipe(concat('sprites.css'))\n    .pipe(gulp.dest('styles/'));\n})\n```\n\n## Rasterize SVG\nIf you add param `raw: true`, plugin just add styles without base64 encoding and css transforms.\nOptions `heigth` and `width` avail for image scaling.\nHere simple example how you can rasterize svg icons and save as `png` files\n```js\nvar gulp = require('gulp'),\n    svgmin = require('gulp-svgmin'),\n    raster = require('gulp-raster'),\n    rename = require('gulp-rename'),\n    svg = require('gulp-svg-inline-css');\n\ngulp.task('inline-svg', function() {\n  gulp.src('*.svg')\n    .pipe(svgmin())\n    .pipe(svg({\n      raw: true,\n      width: 48,\n      height: 48,\n      style: {\n        fill: '#E08283'\n      }\n    }))\n    .pipe(raster())\n    .pipe(rename({\n      extname: '.png'\n    }))\n    .pipe(gulp.dest('processed/'));\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundercloud%2Fgulp-svg-inline-css","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fundercloud%2Fgulp-svg-inline-css","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundercloud%2Fgulp-svg-inline-css/lists"}