Just append #spritename
to the end of image url. No complicated mechanism or strict folder structure.
Plugin moving all retina images, with any ratio to separate sprite. To achieve this all retina images should be declarated with @2x
suffix (where number is image ratio).
Large project got huge time to compile. This plugin check your files md5 and compile only new sprites. No more silly work! (not first time, yet)
Plugin support relative/absolute paths on input file, but still can generate only relative paths on output file (i'm working on it)
imagePath
path for resolve absolute imagesspritePath
path for write completed spritesstylesheetPath
path for resolve relative images (overriding options, css file folder used for default)
.arrow {
background-image: url('/images/arrow-next.png#elements');
}
.arrow:hover {
background-image: url('/images/arrow-next_hover.png#elements');
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
.arrow {
background-image: url('images/[email protected]#elements');
}
.arrow:hover {
background-image: url('/images/[email protected]#elements');
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 2.5) {
.arrow {
background-image: url('images/[email protected]#elements');
}
.arrow:hover {
background-image: url('images/[email protected]#elements');
}
}
.arrow {
background-image: url(sprites/elements.png);
background-position: 0 0;
}
.arrow:hover {
background-image: url(sprites/elements.png);
background-position: -28px 0;
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
.arrow {
background-image: url(sprites/[email protected]);
background-position: 0 0;
}
.arrow:hover {
background-image: url(sprites/[email protected]);
background-position: -56px 0;
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 2.5) {
.arrow {
background-image: url(sprites/[email protected]);
background-position: 0 0;
}
.arrow:hover {
background-image: url(sprites/[email protected]);
background-position: -84px 0;
}
}
postcss([
easysprite({
imagePath:'./public/images',
spritePath: './public/sprites'
})
])
See [PostCSS] docs for examples for your environment.