What is detective-sass?
The detective-sass npm package is designed to analyze SASS (.scss) files to find and extract import statements. This can be particularly useful in build tools and bundlers where understanding dependencies between stylesheets is necessary for tasks like concatenation, minification, or modular builds. It parses the content of SASS files and returns an array of strings representing the paths of files that are imported.
Extract import paths from a SASS file
This feature allows you to pass in the content of a SASS file as a string to the detective function, which then returns an array of the import paths found within that file. This is useful for tracking dependencies in SASS projects.
const detective = require('detective-sass');
const content = `$importedVar: #123;
@import 'another-file';
body { color: $importedVar; }`;
const imports = detective(content);
console.log(imports); // ['another-file']