Find all asset files in a CSS AST
npm install css-find-assets
Find all assets referenced by a CSS AST by searching for properties usingurl(...).
``js
var find = require('css-find-assets'),
parse = require('css-parse');
var tree = parse('.test { background-image: url("test.png"); }'),
assets = find(tree);
console.log(assets);
// [
// {
// url: 'test.png',
// node: { ... },
// position: { index: 0, length: 15 }
// }
// ]
`
Finds all assets referenced by the CSS AST in tree. The AST must be in the
format that css-parse generates.
Returns an array of objects that each have a url property that specifies thenode
URL referenced, a property that contains a reference to the AST nodeposition
that references the asset, and a property that specifies the
location in value that the reference was found.
The position object contains index and length properties that specify theurl(...)` call that
starting index and the length, respectively, of the
references the URL.