PostCSS plugin for easy url() rewriting.
npm install postcss-urlrewrite
Usage example:
// dependencies
var fs = require( 'fs' );
var postcss = require( 'postcss' );
var urlrewrite = require( 'postcss-urlrewrite' );
// css to be processed
var css = fs.readFileSync( 'build/build.css', 'utf8' );
// config for urlrewrite
var config = {
imports: true,
properties: [ 'background', 'content' ],
rules: [
{ from: \local\, to: 'global' },
{ from: \local2\, to: 'global2' }
]
};
// process css using postcss-urlrewrite
var out = postcss()
.use( urlrewrite( config ) )
.process( css )
.css;
Type: boolean
Default: false
If set to true will replace urls in @import at-rules.
Type: array or boolean
Default: true
List of css-properties to replace. If set to true, will work with all
properties. If set to array will work only with the properties in the list.
Type: array of objects or function
There is to way to set rules: