{"id":19635588,"url":"https://github.com/2createstudio/gulp-image-to-rule","last_synced_at":"2025-04-28T08:30:36.672Z","repository":{"id":33413338,"uuid":"37058576","full_name":"2createStudio/gulp-image-to-rule","owner":"2createStudio","description":"Generate CSS rules from your images.","archived":false,"fork":false,"pushed_at":"2016-10-14T15:38:34.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-10T20:08:19.643Z","etag":null,"topics":[],"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/2createStudio.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":"2015-06-08T09:45:20.000Z","updated_at":"2016-08-23T08:44:21.000Z","dependencies_parsed_at":"2022-08-25T21:22:41.689Z","dependency_job_id":null,"html_url":"https://github.com/2createStudio/gulp-image-to-rule","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/2createStudio%2Fgulp-image-to-rule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2createStudio%2Fgulp-image-to-rule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2createStudio%2Fgulp-image-to-rule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2createStudio%2Fgulp-image-to-rule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2createStudio","download_url":"https://codeload.github.com/2createStudio/gulp-image-to-rule/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224101846,"owners_count":17256035,"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-11-11T12:25:57.683Z","updated_at":"2024-11-11T12:25:58.329Z","avatar_url":"https://github.com/2createStudio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-image-to-rule [![Build Status](https://travis-ci.org/2createStudio/gulp-image-to-rule.svg?branch=master)](https://travis-ci.org/2createStudio/postcss-sprites) [![npm version](https://badge.fury.io/js/gulp-image-to-rule.svg)](http://badge.fury.io/js/gulp-image-to-rule)\n[Gulp](https://github.com/gulpjs/gulp) plugin that generate CSS rules from a folder with images.\n\n## Install\n\n```\nnpm install gulp-image-to-rule\n```\n\n## Example\n\n```javascript\nvar path = require('path');\nvar gulp = require('gulp');\nvar i2r  = require('gulp-image-to-rule');\n\ngulp.task('lazy-rules', function() {\n\treturn gulp.src('./src/*.png')\n\t\t.pipe(i2r(path.resolve('./dist/sprite.css')))\n\t\t.pipe(gulp.dest('.'));\n});\n```\n\n## Output\n```css\n.circle { background: url(../src/circle.png) no-repeat 0 0; width: 25px; height: 25px; }\n.square { background: url(../src/square.png) no-repeat 0 0; width: 25px; height: 25px; }\n\n@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {\n\t.circle { background: url(../src/circle@2x.png) no-repeat 0 0; width: 25px; height: 25px; background-size: 25px 25px; }\n\t.square { background: url(../src/square@2x.png) no-repeat 0 0; width: 25px; height: 25px; background-size: 25px 25px; }\n}\n```\n\n\n## Options\n\n#### selectorWithPseudo\n\nType: `String`  \nDefault: `null`  \nExample: `.{base}-{pseudo}, a:{pseudo} .{base}, button:{pseudo} .{base}, .{base}, a.{pseudo} .{base}, button.{pseudo} .{base}, .{base}.{pseudo}`  \nRequired: `false`\n\nCan define custom selector, when pseudo selector is detected. Pseudo selectors are separated from the selectors by '_' in the image name (e.g. `git-icon_hover`). Use keywords `{base}` and `{pseudo}`, that will be replaced in the output.\n\n\n#### templates\n\nType: `Object`  \nDefault: `null`  \nExample:\n```\n{\n\tREGULAR: '\u003c% _.forEach(images, function(image) { %\u003e\u003c%= image.selector %\u003e { background: url(\u003c%= image.url %\u003e) no-repeat 0 0; width: \u003c%= image.dimensions.width %\u003epx; height: \u003c%= image.dimensions.height %\u003epx; display: inline-block; vertical-align: middle; font-size: 0; }\u003c%= \\'\\\\n\\' %\u003e\u003c% }); %\u003e',\n    \n\tRETINA: '@media (-webkit-min-device-pixel-ratio: \u003c%= ratio %\u003e), (min-resolution: \u003c%= dpi %\u003edpi) {\u003c% _.forEach(images, function(image) { %\u003e\u003c%= \\'\\\\n\\\\t\\' + image.selector %\u003e { background: url(\u003c%= image.url %\u003e) no-repeat 0 0; width: \u003c%= image.dimensions.width / image.ratio %\u003epx; height: \u003c%= image.dimensions.height / image.ratio %\u003epx; background-size: \u003c%= image.dimensions.width / image.ratio %\u003epx \u003c%= image.dimensions.height / image.ratio %\u003epx; display: inline-block; vertical-align: middle; font-size: 0; }\u003c% }); %\u003e}'\n}\n```\nRequired: `false`\n\nCan define custom templates for regular and retina CSS output using lodash templates.\n\n\n## Notes\n\n- The plugin has built-in support for retina images.\n- The CSS selectors are based on name of file e.g `ico-arrow.png =\u003e .ico-arrow`.\n- The purpose of this plugin is to be like a preprocessor for the [postcss-sprites](https://github.com/2createStudio/postcss-sprites) plugin.\n\n## Contributing\n\nPull requests are welcome.\n\n## License\nMIT © 2createStudio\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2createstudio%2Fgulp-image-to-rule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2createstudio%2Fgulp-image-to-rule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2createstudio%2Fgulp-image-to-rule/lists"}