Miss any of our Open RFC calls?Watch the recordings here! »

postcss-image-set-polyfill

1.0.0 • Public • Published

postcss-image-set-polyfill Build Status npm version

PostCSS plugin for polyfilling image-set CSS function.

/* Input example */
.foo {
    background-image: image-set(url(img/test.png) 1x,
                                url(img/test-2x.png) 2x,
                                url(my-img-print.png) 600dpi);
}
/* Output example */
.foo {
    background-image: url(img/test.png);
}
 
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .foo {
        background-image: url(img/test-2x.png);
    }
}
 
 
@media (-webkit-min-device-pixel-ratio: 6.25), (min-resolution: 600dpi) {
    .foo {
        background-image: url(my-img-print.png);
    }
}

→Try it online←

❗️ Resolution media query is supported only by IE9+.

Installation

npm i postcss-image-set-polyfill -D

️❕ NodeJS version must be 6+.

Usage

var postcssImageSet = require('postcss-image-set-polyfill');
 
postcss([postcssImageSet]).process(YOUR_CSS, /* options */);

See PostCSS docs for examples for your environment.

⚠️️ Warning

If you use autoprefixer, place this plugin before it to prevent styles duplication.

Install

npm i postcss-image-set-polyfill

DownloadsWeekly Downloads

203,840

Version

1.0.0

License

MIT

Unpacked Size

25.2 kB

Total Files

11

Last publish

Collaborators

  • avatar