PostCSS plugin to rebase, inline or copy the files in url()
open sourceMITfree
postcss-url is a PostCSS plugin that rewrites the assets referenced in CSS url() values. It can rebase relative paths to the output file's location, inline images and SVGs as data URIs, or copy the files into an assets folder, optionally with content-hash names.
Problems it solves
- fix broken image paths in CSS after bundling it into another folder
- inline small images into my CSS as data URIs
- copy the images my CSS references into the build output
Features
- rebase relative url() paths to the output file
- inline images as base64 and SVGs as URI-encoded data URIs
- copy referenced assets to an output folder, with hashed names
Limitations
- Version 10 needs Node.js 22 or newer and PostCSS 8.1
