Skip to content

smitt04/postcss-prefix-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcss-prefix-url

PostCSS plugin to prefix your urls

Installation

npm i postcss-prefix-url

or

yarn add postcss-prefix-url

Options

Option Type Description
prefix Array or String The strings or string to prefix your url paths with
[useUrl = false] Boolean If set to TRUE then the url()'s will also be prefixed, otherwise ignores them
[exclude] Regex Exclude url paths matching this regex

Examples

Input

body {
  background: cdn('/test.png');
}

.testAbsolute {
  background: cdn(http://absolute.com/test1.png); /* Ignore absolute urls */
}

.withUrl {
  background: url(/testUrl.png);
}

.testExclude {
  background: cdn(/exclude-this/test1.png); /* Exclude this url */
}

Output

body {
  background: url(https://img1.example.com/test.png);
}

.testAbsolute {
  background: url(http://absolute.com/test1.png);
}

.withUrl {
  background: url(https://img1.example.com/testUrl.png);
}

.testExclude {
  background: url(/exclude-this/test1.png);
}