postcss-urlrewrite
PostCSS plugin for easy url() rewriting.
Getting Started
npm install postcss-urlrewrite
Example
Usage example:
// dependenciesvar fs = ;var postcss = ;var urlrewrite = ; // css to be processedvar css = fs; // config for urlrewritevar config = imports: true properties: 'background' 'content' rules: from: \local\ to: 'global' from: \local2\ to: 'global2' ; // process css using postcss-urlrewritevar out = css;
Configuration
imports
Type: boolean Default: false
If set to true will replace urls in @import at-rules.
properties
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.
rules
Type: array of objects or function
There is to way to set rules:
- Create array of objects with "from" and "to" keys. "from" can be String or RegExp, "to" can be String or Function. See String.replace() syntax for details. ONLY first matching rule will be triggered on each URI.
- Create function that will work with URIjs objects and mutate them one way or another.