{"id":20410365,"url":"https://github.com/jeff2ma/postcss-lazyimagecss","last_synced_at":"2025-06-21T20:05:12.006Z","repository":{"id":83011532,"uuid":"70386923","full_name":"Jeff2Ma/postcss-lazyimagecss","owner":"Jeff2Ma","description":"A PostCSS plugin that generates images's CSS width \u0026 height properties automatically.","archived":false,"fork":false,"pushed_at":"2017-09-06T15:06:24.000Z","size":69,"stargazers_count":38,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T20:05:03.019Z","etag":null,"topics":["css","nodejs","postcss","postcss-lazyimagecss","postcss-plugin"],"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/Jeff2Ma.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}},"created_at":"2016-10-09T07:54:35.000Z","updated_at":"2025-01-21T00:36:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"94639b3a-3466-4258-848c-dcac42502f49","html_url":"https://github.com/Jeff2Ma/postcss-lazyimagecss","commit_stats":{"total_commits":31,"total_committers":4,"mean_commits":7.75,"dds":"0.22580645161290325","last_synced_commit":"8cbfc38ba9a82f183c69f776b9ef0a58440aad52"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jeff2Ma/postcss-lazyimagecss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeff2Ma%2Fpostcss-lazyimagecss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeff2Ma%2Fpostcss-lazyimagecss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeff2Ma%2Fpostcss-lazyimagecss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeff2Ma%2Fpostcss-lazyimagecss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jeff2Ma","download_url":"https://codeload.github.com/Jeff2Ma/postcss-lazyimagecss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeff2Ma%2Fpostcss-lazyimagecss/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261186769,"owners_count":23121943,"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":["css","nodejs","postcss","postcss-lazyimagecss","postcss-plugin"],"created_at":"2024-11-15T05:45:51.469Z","updated_at":"2025-06-21T20:05:06.987Z","avatar_url":"https://github.com/Jeff2Ma.png","language":"JavaScript","readme":"# postcss-lazyimagecss \n\n[![Greenkeeper badge](https://badges.greenkeeper.io/Jeff2Ma/postcss-lazyimagecss.svg)](https://greenkeeper.io/)\n\n\u003cimg align=\"right\" width=\"130\" height=\"130\" title=\"PostCSS\" src=\"http://postcss.github.io/postcss/logo.svg\"\u003e\n\n[![Build Status](https://travis-ci.org/Jeff2Ma/postcss-lazyimagecss.svg?branch=master)](https://travis-ci.org/Jeff2Ma/postcss-lazyimagecss)\n[![npm version](https://badge.fury.io/js/postcss-lazyimagecss.svg)](http://badge.fury.io/js/postcss-lazyimagecss)\n\nA [PostCSS](https://github.com/postcss/postcss) plugin that generates images's CSS `width` \u0026 `height` properties from stylesheets automatically.\n\nAnother lazy way to write CSS, feel free to use it :)\n\nBased on [gulp-lazyimagecss](https://github.com/weixin/gulp-lazyimagecss). Thanks to [hzlzh](https://github.com/hzlzh) and [littledu](https://github.com/littledu).\n\n```css\n/* Input */\n.icon-close {\n\tbackground-image: url(../slice/icon-close.png); //icon-close.png - 16x16\n}\n\n.icon-new {\n\tbackground-image: url(../slice/icon-new@2x.png); //icon-new@2x.png - 16x16\n}\n\t\n/* Output */\n.icon-close {\n\tbackground-image: url(../slice/icon-close.png);\n\twidth: 16px;\n\theight: 16px;\n}\n\n.icon-new {\n\tbackground-image: url(../slice/icon-new@2x.png);\n\twidth: 8px;\n\theight: 8px;\n\tbackground-size: 8px 8px;\n}\n\n```\n\n## Features\n\n- Support `jpg`/`jpeg`/`png`/`gif`/`bmp`/`svg` file type.\n\n- Support retina image (file name should like `demo@2x.png`).\n\n- Both `background-image: url()` and `background: url()` can be detected successfully.\n\n- CSS property generating will be ignored if any of those `width` / `height` / `background-size` already set.\n\n\n## Installation\n\nInstall with npm:\n\n\tnpm install postcss-lazyimagecss --save-dev\n\t\n\nOr install width [yarn](https://github.com/yarnpkg/yarn):\n\n\tyarn add postcss-lazyimagecss --dev\n\n## Usage\n\n### Work with [Gulp](http://gulpjs.com/)\n\nExample:\n\n```js\nvar gulp = require('gulp');\nvar postcss = require('gulp-postcss');\nvar lazyimagecss = require('postcss-lazyimagecss');\n\ngulp.task('css', function () {\n\treturn gulp.src('./src/css/*.css')\n\t    .pipe(another-plugin())\n\t\t.pipe(postcss([lazyimagecss({\n\t\t\timagePath: ['../img','../slice']\n\t\t})]))\n\t\t.pipe(gulp.dest('./dist/css'));\n});\n```\t\n\n### Work with Gulp \u0026 [gulp-sourcemaps](https://www.npmjs.com/package/gulp-sourcemaps)\n\nExample:\n\n```js\nvar gulp = require('gulp');\nvar postcss = require('gulp-postcss');\nvar lazyimagecss = require('postcss-lazyimagecss');\nvar sourcemaps = require('gulp-sourcemaps');\n\ngulp.task('css', function () {\n\treturn gulp.src('./src/css/*.css')\n\t\t.pipe(sourcemaps.init())\n\t\t.pipe(another-plugin())\n\t\t.pipe(postcss([lazyimagecss({\n\t\t\timagePath: ['../img','../slice']\n\t\t})]))\n\t\t.pipe(sourcemaps.write(\".\"))\n\t\t.pipe(gulp.dest('./dist'));\n});\n```\n\n## Options\n- **imagePath** Set image path to be worked (e.g. `['../slice','../img']`)\n\n- **width**  Whether output `width` properties in CSS ( default: `true` )\n\n- **height**  Whether output `height` properties in CSS ( default: `true` )\n\n- **backgroundSize** Whether output `background-size` properties in CSS ( default: `true` )\n\n## Contributing\n\n[Issues](https://github.com/Jeff2Ma/postcss-lazyimagecss/issues/) and [Pull requests](https://github.com/Jeff2Ma/postcss-lazyimagecss/pulls) are welcome.\n\n```shell\n$ git clone https://github.com/Jeff2Ma/postcss-lazyimagecss\n$ cd postcss-lazyimagecss\n$ npm i\n$ gulp\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeff2ma%2Fpostcss-lazyimagecss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeff2ma%2Fpostcss-lazyimagecss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeff2ma%2Fpostcss-lazyimagecss/lists"}