css-find-assets

0.0.3 • Public • Published

css-find-assets

Build Status

Find all assets referenced by a CSS AST by searching for properties using url(...).

Example

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 }
//   }
// ]

Reference

findAssets(tree)

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 the URL referenced, a node property that contains a reference to the AST node that references the asset, and a position property that specifies the location in value that the reference was found.

The position object contains index and length properties that specify the starting index and the length, respectively, of the url(...) call that references the URL.

Readme

Keywords

none

Package Sidebar

Install

npm i css-find-assets

Weekly Downloads

60

Version

0.0.3

License

BSD

Last publish

Collaborators

  • conradz