css-detective
Find all @import
s by walking the AST (similar to and inspired by detective, but for CSS)
example
strings
style.css:
@;@;@;
strings.js:
var cssDetective =var fs =var src = fsvar imports =consoledirimports
output:
$ node examples/strings.js
[ 'a', 'b', 'c' ]
methods
var cssDetective =
cssDetective(src, opts)
Give some source body src
, return an array of all the @import
s.
The options parameter opts
is passed along to cssDetective.find()
.
var found = cssDetective.find(src, opts)
Give some source body src
, return found
with:
found.strings
- an array of each string found in an@import
found.nodes
(whenopts.nodes === true
) - an array of AST nodes for each argument found in an@import
Optionally:
opts.nodes
- whentrue
, populatefound.nodes
opts.isImport(node)
- a function returning whether an AST node is an importopts.parse
- supply options directly to postcss
install
With npm do:
npm install css-detective
license
ISC