postcss-map-url

1.0.2 • Public • Published

postcss-map-url Build Status

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.

Package Sidebar

Install

npm i postcss-map-url

Weekly Downloads

18

Version

1.0.2

License

MIT

Last publish

Collaborators

  • simonsmith