postcss-lazyimagecss
A PostCSS plugin that generates images's CSS width
& height
properties from stylesheets automatically.
Another lazy way to write CSS, feel free to use it :)
Based on gulp-lazyimagecss. Thanks to hzlzh and littledu.
/* Input */ /* Output */
Features
-
Support
jpg
/jpeg
/png
/gif
/bmp
/svg
file type. -
Support retina image (file name should like
demo@2x.png
). -
Both
background-image: url()
andbackground: url()
can be detected successfully. -
CSS property generating will be ignored if any of those
width
/height
/background-size
already set.
Installation
Install with npm:
npm install postcss-lazyimagecss --save-dev
Or install width yarn:
yarn add postcss-lazyimagecss --dev
Usage
Gulp
Work withExample:
var gulp = ;var postcss = ;var lazyimagecss = ; gulp;
gulp-sourcemaps
Work with Gulp &Example:
var gulp = ;var postcss = ;var lazyimagecss = ;var sourcemaps = ; gulp;
Options
-
imagePath Set image path to be worked (e.g.
['../slice','../img']
) -
width Whether output
width
properties in CSS ( default:true
) -
height Whether output
height
properties in CSS ( default:true
) -
backgroundSize Whether output
background-size
properties in CSS ( default:true
)
Contributing
Issues and Pull requests are welcome.
$ git clone https://github.com/Jeff2Ma/postcss-lazyimagecss$ cd postcss-lazyimagecss$ npm i$ gulp