{"id":22031633,"url":"https://github.com/bsara/css-dep-tree","last_synced_at":"2026-04-09T16:04:10.485Z","repository":{"id":79821679,"uuid":"84132988","full_name":"bsara/css-dep-tree","owner":"bsara","description":"Generates a CSS dependency tree and dependency file/URL lists based on CSS imports","archived":false,"fork":false,"pushed_at":"2017-04-22T19:42:02.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-23T09:14:53.189Z","etag":null,"topics":["css","dependencies","dependency","dependency-tree","tree"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/css-dep-tree","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-06T23:52:03.000Z","updated_at":"2019-02-21T20:47:04.000Z","dependencies_parsed_at":"2023-04-23T11:34:28.061Z","dependency_job_id":null,"html_url":"https://github.com/bsara/css-dep-tree","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.0625,"last_synced_commit":"30b2dcbf3aefc8aa8894fa8308db2eb77062b412"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsara%2Fcss-dep-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsara%2Fcss-dep-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsara%2Fcss-dep-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsara%2Fcss-dep-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsara","download_url":"https://codeload.github.com/bsara/css-dep-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097851,"owners_count":20560316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","dependencies","dependency","dependency-tree","tree"],"created_at":"2024-11-30T08:19:29.286Z","updated_at":"2026-04-09T16:04:10.457Z","avatar_url":"https://github.com/bsara.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# css-dep-tree [![NPM Package](https://img.shields.io/npm/v/css-dep-tree.svg?style=flat-square)][npm]\n\n[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square)][license]\n\n\u003e Generates a CSS dependency tree and dependency file/URL lists based on CSS imports\n\n\n[Changelog](https://github.com/bsara/css-dep-tree/blob/master/CHANGELOG.md)\n\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n\n# Install\n\n**Project Install**\n```bash\n$ npm install --save css-dep-tree\n```\n\n**Global Install**\n```bash\n$ npm install -g css-dep-tree\n```\n\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n\n\n# Usage\n\n#### Node Library:\n\n```javascript\nlet cssDepTree = require('css-dep-tree');\n\n// `cssDepTree` returns a `Promise`\ncssDepTree('main.css').then((results) =\u003e {\n  console.log(results);\n})\n.catch((err) =\u003e {\n  console.error(err);\n});\n\n// `cssDepTree` will also accept a callback\ncssDepTree('main.css', (err, results) =\u003e {\n  if (err) {\n    console.error(err);\n    return;\n  }\n\n  console.log(results);\n});\n```\n\n\n#### Command Line Tool:\n\n```sh\n$ cssdt -h\n\n  Usage:\n    (cssdt|cssdeptree) \u003ccssFile\u003e [options]\n\n  Options:\n    -r  --relative       Output files paths relative to current directory\n\n    -l  --files-list     Only show list of file dependencies\n    -u  --urls-list      Only show list of URL dependencies\n\n    -L  --exclude-files  Exclude all files from output\n    -U  --exclude-urls   Exclude all URL dependencies from output\n    -T  --exclude-tree   Exclude dependency tree from output (only file and URL lists will be present)\n\n    -c  --compress       Compress output JSON\n\n    -h  --help           Show this message\n    -V  --version        Show version number\n```\n\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n\n# API\n\n## cssDepTree(filePath, [options], [callback])\n\nBuilds a dependency tree and lists of all file and URL dependencies.\n\n\n### Parameters\n\n- **filePath** `String`\u003cbr/\u003e\n  Path to entry CSS file.\n\n- **options** `Object` or `Function`\u003cbr/\u003eOperation options. *(If `options` is a `Function`, then it is assumed to be the `callback` parameter).*\n  - **relative** `Boolean` *(Default: `false`)*\u003cbr/\u003e\n    If `true`, all file paths in results are expressed relative to the current directory.\n  - **excludeTree** `Boolean` *(Default: `false`)*\u003cbr/\u003e\n    If `true`, full dependency tree object is excluded from results.\n  - **excludeFiles** `Boolean` *(Default: `false`)*\u003cbr/\u003e\n    If `true`, all file dependency paths are excluded from results.\n  - **excludeURLs** `Boolean` *(Default: `false`)*\u003cbr/\u003e\n    If `true`, all URL dependency paths are excluded from results.\n\n- **callback(err, results)** `Function`\u003cbr/\u003e\n  Callback function to execute when operation has completed.\n\n### Return Value\n\n**Type:** `Promise\u003cObject\u003e`\n\n\nThe `Object` returned by the `callback` function parameter and `Promise` resolved callback\nhas three properties:\n\n\n- **tree** `Object`\u003cbr/\u003e\n  Represents the full dependency tree. *(Not present if `options.excludeTree` is `true`)*\n\n- **urls** `String[]`\u003cbr/\u003e\n  Contains all dependency URL paths found in the dependency tree. *(Not present if `options.excludeFiles` is `true`)*\n\n- **files** `String[]`\u003cbr/\u003e\n  Contains all dependency file paths found in the dependency tree. *(Not present if `options.excludeURLs` is `true`)*\n\n\n\u003e **NOTE:** Each unique URL and file path will appear only once in the `urls` \u0026 `files`\nlists, regardless of how many times it appears ion the dependency tree.\n\n\n#### Example Results Object\n\n```javascript\n{\n  tree: {\n    \"file/path/root.css\": {\n      \"urls\": [\n        \"//example.com/my/css/url0.css\",\n        \"http://example.com/my/css/url1.css\",\n        \"https://example.com/my/css/url2.css\"\n      ],\n      files: {\n        \"file/path/otherRootFile0.css\": null,\n        \"file/path/otherRootFile1.css\": null,\n        \"file/path/otherRootFile2.css\": null,\n        \"file/path/sub-dir/subDirFile.css\": {\n          urls: [\n            \"//example.com/my/css/url0.css\",\n            \"//example.com/some/url\"\n          ],\n          files: {\n            \"file/path/otherRootFile1.css\": null\n          }\n        }\n      }\n    }\n  },\n  urls: [\n    \"//example.com/my/css/url0.css\",\n    \"http://example.com/my/css/url1.css\",\n    \"https://example.com/my/css/url2.css\",\n    \"//example.com/some/url\"\n  ],\n  files: [\n    \"file/path/otherRootFile0.css\",\n    \"file/path/otherRootFile1.css\",\n    \"file/path/otherRootFile2.css\",\n    \"file/path/sub-dir/subDirFile.css\"\n  ]\n}\n```\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n## cssDepTree.files(filePath, [relative], [callback])\n\nBuilds a flat list of all file dependencies found in the dependency tree.\n\n\n### Parameters\n\n- **filePath** `String`\u003cbr/\u003e\n  Path to entry CSS file.\n\n- **relative** `Boolean` or `Function` *(Default: `false`)*\u003cbr/\u003e\n  If `true`, all file paths in results are expressed relative to the current directory.\n  *(If `relative` is a `Function`, then it is assumed to be the `callback` parameter).*\n\n- **callback(err, results)** `Function`\u003cbr/\u003e\n  Callback function to execute when operation has completed.\n\n\n### Return Value\n\n**Type:** `Promise\u003cString[]\u003e`\n\n\u003e **NOTE:** Each unique file path will appear only once in the returned `String[]`,\nregardless of how many times it appears ion the dependency tree.\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n## cssDepTree.urls(filePath, [relative], [callback])\n\nBuilds a flat list of all URL dependencies found in the dependency tree.\n\n\n### Parameters\n\n- **filePath** `String`\u003cbr/\u003e\n  Path to entry CSS file.\n\n- **relative** `Boolean` or `Function` *(Default: `false`)*\u003cbr/\u003e\n  If `true`, all file paths in results are expressed relative to the current directory.\n  *(If `relative` is a `Function`, then it is assumed to be the `callback` parameter).*\n\n- **callback(err, results)** `Function`\u003cbr/\u003e\n  Callback function to execute when operation has completed.\n\n\n### Return Value\n\n**Type:** `Promise\u003cString[]\u003e`\n\n\u003e **NOTE:** Each unique URL will appear only once in the returned `String[]`, regardless\nof how many times it appears ion the dependency tree.\n\n\n\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n\n# License\n\nISC License (ISC)\n\nCopyright (c) 2017 Brandon Sara (http://bsara.github.io/)\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n\n\n\n\n[license]: https://github.com/bsara/css-dep-tree/blob/master/LICENSE \"License\"\n[npm]:     https://www.npmjs.com/package/css-dep-tree \"NPM Package: css-dep-tree\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsara%2Fcss-dep-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsara%2Fcss-dep-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsara%2Fcss-dep-tree/lists"}