{"name":"detective-postcss","version":"9.0.1","description":"Detective to find dependents of CSS (PostCSS dialect)","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"repository":{"type":"git","url":"git+https://github.com/dependents/node-detective-postcss.git"},"bugs":{"url":"https://github.com/dependents/node-detective-postcss/issues"},"homepage":"https://github.com/dependents/node-detective-postcss#readme","keywords":[],"author":{"name":"Joscha Feth","email":"joscha@feth.com"},"license":"MIT","engines":{"node":">=20.19.0 || >=22.12.0"},"peerDependencies":{"postcss":"^8.4.47"},"dependencies":{"is-url-superb":"^4.0.0","postcss-values-parser":"^6.0.2"},"devDependencies":{"@types/node":"^20.19.41","@vitest/coverage-v8":"^4.1.9","nano-staged":"^1.0.2","postcss":"^8.5.15","prettier":"^3.8.4","rimraf":"^6.1.3","typescript":"^6.0.3","vitest":"^4.1.7"},"scripts":{"build":"rimraf ./dist && npm run compile","compile":"tsc","prepack":"npm run build","pretest":"prettier --check .","test":"vitest run","test:watch":"vitest","precommit":"nano-staged","prettier":"prettier --write ."},"gitHead":"96e4be86d94d7c674299dff593fa3fd13aae15fa","_id":"detective-postcss@9.0.1","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-rTAmnRsU28hpuYn1317ddubhi9i2zreiKpQlzddHQNgliiwG9AjAyoRDEUt+9Y6wlH/QQgdKmXWQw7VTv0zJmQ==","shasum":"8c6cbf80fbabb2254d9ed5d6d8b7c158b9358071","tarball":"http://registry-npm.ywwl.com/detective-postcss/download/detective-postcss-9.0.1.tgz","fileCount":5,"unpackedSize":10538,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/detective-postcss@9.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCptTn+e3sh7Q8DRoMxAGydjnLeN+6kiErYvTUtuBoISgIhANP49rwitsXbOwl2/gka+7nRSUxxZTaW+6iHhEm6Ep/5"}],"size":4046,"noattachment":false,"key":"/detective-postcss/-/detective-postcss-9.0.1.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:783ced02-e9a7-48b4-ab9e-b31a4e9f9370"}},"directories":{},"maintainers":[{"name":"joscha","email":"joscha@feth.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/detective-postcss_9.0.1_1782892663390_0.9699438224754449"},"_hasShrinkwrap":false,"readme":"# node-detective-postcss\n\n[![build](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-postcss/node.js.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-postcss/actions/workflows/node.js.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/detective-postcss?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-postcss)\n[![npm downloads](https://img.shields.io/npm/dm/detective-postcss)](https://www.npmjs.com/package/detective-postcss)\n\n> Find the dependencies of a CSS file (PostCSS dialect)\n\nSupports `@import` and [`@value ... from`](https://github.com/css-modules/postcss-icss-values). Absolute and protocol-relative URLs are automatically filtered out.\n\nThe AST is generated using [postcss](https://github.com/postcss/postcss) and [postcss-values-parser](https://github.com/shellscape/postcss-values-parser).\n\n## Installation\n\n```sh\nnpm install detective-postcss\n```\n\n`postcss` must be installed separately as a peer dependency:\n\n```sh\nnpm install postcss\n```\n\n## Usage\n\n```js\n// ESM\nimport { readFileSync } from 'node:fs';\nimport detective from 'detective-postcss';\n// CommonJS\nconst { readFileSync } = require('node:fs');\nconst detective = require('detective-postcss');\n\nconst content = readFileSync('styles.css', 'utf8');\n\n// Returns an array of imported file paths (e.g. ['foo.css', 'bar.css'])\nconst dependencies = detective(content);\n\n// Also include url() references (images, fonts, etc.) found in declarations\nconst allDependencies = detective(content, { url: true });\n```\n\n## API\n\n### `detective(src, options?)`\n\n| Parameter     | Type      | Required | Description                                                                                                                |\n| ------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |\n| `src`         | `string`  | Yes      | CSS source code to analyse                                                                                                 |\n| `options.url` | `boolean` | No       | When `true`, also extracts `url()` references from declarations (e.g. `background`, `src`, `cursor`). Defaults to `false`. |\n\nReturns `string[]` - the list of local dependency paths found in the source.\n\nThrows `detective.MalformedCssError` if `src` cannot be parsed.\n\n#### What is detected\n\n| Syntax                     | Example                            | Detected by default       |\n| -------------------------- | ---------------------------------- | ------------------------- |\n| `@import \"file.css\"`       | `@import \"theme.css\"`              | yes                       |\n| `@import url(file.css)`    | `@import url(print.css)`           | yes                       |\n| `@value x from \"file.css\"` | `@value primary from 'colors.css'` | yes                       |\n| `url()` in declarations    | `background: url(bg.png)`          | only with `{ url: true }` |\n\nAbsolute URLs (`https://...`) and protocol-relative URLs (`//...`) are always ignored.\n\n## Related\n\nThis is the CSS (PostCSS dialect) counterpart to:\n\n- [detective-cjs](https://github.com/dependents/node-detective-cjs) - CommonJS\n- [detective-amd](https://github.com/dependents/node-detective-amd) - AMD\n- [detective-es6](https://github.com/dependents/node-detective-es6) - ES modules\n- [detective-sass](https://github.com/dependents/node-detective-sass) - Sass\n- [detective-scss](https://github.com/dependents/node-detective-scss) - SCSS\n\n## Releasing\n\n1. Ensure CI is green on `main`.\n2. Preview what would be included in the package without publishing: `npm pack --dry-run`.\n3. Bump the version following [semver](https://semver.org/) (this also creates the `vX.Y.Z` tag): `npm version <patch|minor|major>`.\n4. Push the commit and tag: `git push --follow-tags`.\n5. Create (or draft) a GitHub release from that `vX.Y.Z` tag, then **Publish** it.\n6. Publishing the release triggers [npm-publish](https://github.com/dependents/node-detective-postcss/actions/workflows/npm-publish.yml) (`release.published`), which runs `npm ci` and `npm publish --provenance`.\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1782892663615,"_cnpm_publish_time":1782892663615,"dist-tags":{"latest":"9.0.1"}}