
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
postcss-sprites-async
Advanced tools
PostCSS plugin that generates spritesheets from your stylesheets.
/* Input */
.comment { background: url(images/sprite/ico-comment.png) no-repeat 0 0; }
.bubble { background: url(images/sprite/ico-bubble.png) no-repeat 0 0; }
/* ---------------- */
/* Output */
.comment { background-image: url(images/sprite.png); background-position: 0 0; }
.bubble { background-image: url(images/sprite.png); background-position: 0 -50px; }
var fs = require('fs');
var postcss = require('postcss');
var sprites = require('postcss-sprites');
var css = fs.readFileSync('./css/style.css', 'utf8');
var opts = {
stylesheetPath: './dist',
spritePath: './dist/images/'
};
postcss([sprites(opts)])
.process(css, {
from: './css/style.css',
to: './dist/style.css'
})
.then(function(result) {
fs.writeFileSync('./dist/style.css', result.css);
});
See PostCSS docs for examples for your environment.
Relative path to the folder that will keep your output stylesheet(s). If it's null the path of CSS file will be used.
falseRelative path to the folder that will keep your output spritesheet(s).
./trueYour base path that will be used for images with absolute CSS urls.
./falseIndicates whether the url should be relative against current CSS context or original CSS stylesheet file.
filefalsefile|ruleDefines filter functions that will manipulate the list of images founded in your stylesheet(s).
[]falseFunction|Function[]Every function must return a Promise which should be resolved or rejected.
Built-in filters:
fs.stat and used to remove non exisiting imagesDefines group functions that will manipulate the list of images founded in your stylesheet(s).
[]falseFunction|Function[]Every function must return a Promise which should be resolved with a string or rejected.
Built-in filters:
@2x naming conventionDefines whether or not to search for retina mark in the filename.
falsefalseDefines whether or not to search for retina mark in the filename.
{}falseHook that allows to rewrite the data of produced spritesheet.
If returned value is string, it is used as filepath value, and if returned value is object, it is used as value which will be merged with current spritesheet data.
Returned value can also be Promise which should return either string or object.
nullfalseHook that allows to rewrite the CSS output for an image.
nullfalseA spritesmith configuration.
{}falseThe engine.
pixelsmithfalseThe algorithm.
binary-treefalseThe space between images in spritesheet.
0falseThe configuration of the engine.
{}falseThe export options of the engine.
{}falseA svg-sprite configuration.
Prints the plugin output to the console.
falsefalseEvery filter or group function will be called with an Image object.
An absolute path to the stylesheet -
/Path/to/your/source/stylesheet.css
An absolute path to the image -
/Path/to/your/image.png
The url found in your stylesheet including the query params -
../image.png?v1
A normalized version of the original url -
../image.png
The retina ratio of your image -
2
Indicates whenever your image is retina -
true
The groups associated with the image -
['shapes', '@2x']
The string used as reference in your stylesheet -
/* @replace|image.png */
The position & dimensions of image in generated spritesheet -
{ width: 20, height: 20, x: 0, y: 0 }
A relative path to the generated spritesheet -
dist/sprite.png
A CSS url to the generated spritesheet -
sprite.png
The total width of the spritesheet -
200
The total height of the spritesheet -
400
Pull requests are welcome.
$ git clone git@github.com:2createStudio/postcss-sprites.git
$ npm install
$ npm run watch
FAQs
Use Async/Await Generate spritesheets from stylesheets
We found that postcss-sprites-async demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.