postcss-prefix-url
v1.0.0
Published
Prefix URLs with CDN
Maintainers
Readme
postcss-prefix-url
PostCSS plugin to prefix your urls
Installation
npm i postcss-prefix-url
or
yarn add postcss-prefix-urlOptions
| 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);
}