npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

detective-postcss

v8.0.3

Published

Detective to find dependents of CSS (PostCSS dialect)

Downloads

20,147,879

Readme

node-detective-postcss

build npm version npm downloads

Find the dependencies of a CSS file (PostCSS dialect)

Supports @import and @value ... from. Absolute and protocol-relative URLs are automatically filtered out.

The AST is generated using postcss and postcss-values-parser.

Installation

npm install detective-postcss

postcss must be installed separately as a peer dependency:

npm install postcss

Usage

const fs = require('node:fs');
const detective = require('detective-postcss');

const content = fs.readFileSync('styles.css', 'utf8');

// Returns an array of imported file paths (e.g. ['foo.css', 'bar.css'])
const dependencies = detective(content);

// Also include url() references (images, fonts, etc.) found in declarations
const allDependencies = detective(content, { url: true });

TypeScript / ESM:

import detective = require('detective-postcss');

const dependencies = detective(content);
const allDependencies = detective(content, { url: true });

API

detective(src, options?)

| Parameter | Type | Required | Description | | ------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------- | | src | string | Yes | CSS source code to analyse | | options.url | boolean | No | When true, also extracts url() references from declarations (e.g. background, src, cursor). Defaults to false. |

Returns string[] - the list of local dependency paths found in the source.

Throws detective.MalformedCssError if src cannot be parsed.

What is detected

| Syntax | Example | Detected by default | | -------------------------- | ---------------------------------- | ------------------------- | | @import "file.css" | @import "theme.css" | yes | | @import url(file.css) | @import url(print.css) | yes | | @value x from "file.css" | @value primary from 'colors.css' | yes | | url() in declarations | background: url(bg.png) | only with { url: true } |

Absolute URLs (https://...) and protocol-relative URLs (//...) are always ignored.

Related

This is the CSS (PostCSS dialect) counterpart to:

Releasing

  1. Ensure CI is green on main.
  2. Preview what would be included in the package without publishing: npm pack --dry-run.
  3. Bump the version following semver (this also creates the vX.Y.Z tag): npm version <patch|minor|major>.
  4. Push the commit and tag: git push --follow-tags.
  5. Create (or draft) a GitHub release from that vX.Y.Z tag, then Publish it.
  6. Publishing the release triggers npm-publish (release.published), which runs npm ci and npm publish --provenance.

License

MIT