postcss-map-url
v1.0.2
Published
PostCSS plugin that maps over each `url` property in a declaration
Downloads
82
Maintainers
Readme
postcss-map-url
Ported from rework-plugin-url
PostCSS plugin that maps over each url
property in a declaration.
Installation
$ npm install postcss-map-url --save-dev
.mapUrl(mapFn)
Takes a callback function that recieves the url
Usage
var fs = require('fs');
var postcss = require('postcss');
var mapUrl = require('postcss-map-url');
var css = fs.readFileSync('input.css', 'utf8');
var output = postcss()
.use(mapUrl(myMapFunc))
.process(css)
.css;
// Your map function that takes the url as a parameter and
// should return a modified url
function myMapFunc(url) {
return 'http://example.com' + url;
}
Input
body {
background: url(/images/bg.png);
}
Output
body {
background: url(http://example.com/images/bg.png);
}
See PostCSS docs for examples for your environment.