postcss-custom-url
Transform url()
in css.
Usage
var url = var util = urlutil var postcss = var path = var fixtures = pathresolve
url(customTransforms)
customTransforms
Type: Array
Default: [ util.rebase ]
An array of transforms.
If an element is not a function,
it should be the name of a method exported by util
:
'copy'
, 'inline'
, 'rebase'
.
transforms
Type: Function
, Array
Signature: transformFn(result, ...args)
Function to transform url,
through modifying result.url
If Array
, the first element should be the transform function,
and elements after the first will be treated as its arguments args
.
result
Type: Result
Result
Properties and methods:
url
:String
from
: The CSS source pathto
: The CSS destination pathfile
: The asset source pathasset
:Asset
.isRelative()
:Function
Result.getFile(url, opts)
. Return thefile
property.Result.dataUrl(file)
Asset
Properties and methods:
mimeType
size()
: Return a promise to get the size of the assetdata()
: Return a promise to get the contents of the assetshasum()
: Return a promise to get the sha1 of the contents of the assetbase64()
: Return a promise to get the base64 of the contents of the assetdataUrl()
: Return a promise to get the data url of the asset
util
A group of transform methods.
rebase
Transform result.url
according to result.to
inline
Transform result.url
to data-url.
Options:
maxSize
:Number
, default:10
. Specify the maximum file size to inline (in kbytes)
copy
Copy asset files to proper destinations and transform result.url
.
Options:
useHash
:Boolean
, default:false
. Iftrue
, assets are renamed by their sha1 hashes.name
:String
, default:null
. Specify how to rename the asset. It only works whenuseHash
is false. Special patterns:[name]
: replaced with the basename of the asset, without the extension.[hash]
: replaced with the hash
assetOutFolder
:String
,Function
. Specify the destination where assets should be copied. IfFunction
, it receives the asset file path andresult.opts
, and should return the output folder. Urls are transformed based on the destination, unlessbaseUrl
is specified.baseUrl
:String
, default:null
. Specify the base url for assets.
var url = var postcss =