Socket
Socket
Sign inDemoInstall

detective-scss

Package Overview
Dependencies
2
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    detective-scss

Find the dependencies of an scss file


Version published
Weekly downloads
1.1M
increased by0.67%
Maintainers
3
Install size
2.43 MB
Created
Weekly downloads
 

Package description

What is detective-scss?

The detective-scss npm package is designed for analyzing SCSS (Sassy CSS) files to find and extract import statements. This can be particularly useful in build tools and bundlers that need to understand dependencies between SCSS files to correctly assemble them. It parses SCSS content and returns an array of strings, each representing an import found within the file.

What are detective-scss's main functionalities?

Extract import statements from SCSS content

This feature allows you to pass SCSS content as a string to the detective function, which then returns an array of the import paths found within that content. It's useful for dependency resolution and bundling processes.

const detective = require('detective-scss');
const content = `$importedVar: #123;
@import 'another-file';
body { color: $importedVar; }`;
const imports = detective(content);
// imports would be ['another-file']

Other packages similar to detective-scss

Readme

Source

detective-scss

CI npm version npm downloads

Find the dependencies of an scss file

npm install detective-scss

Note: This is specific to the .scss style syntax of the Sass preprocessor. For Sass support, please see node-detective-sass.

It's the SASS counterpart to detective, detective-amd, and detective-es6.

  • The AST is generated using the gonzales-pe parser.

Usage

const fs = require('fs');
const detective = require('detective-scss');

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

// list of imported file names (ex: '_foo.scss', '_foo', etc)
const dependencies = detective(content);

// or to also detect any url() references to images, fonts, etc.
const allDependencies = detective(content, { url: true });

Options

  • url (optional): (Boolean) also detect any url() references to images, fonts, etc.
  • node-sass-lookup if you want to map a sass/scss dependency to a file on your filesystem.
  • node-precinct if you want to also support finding dependencies for JavaScript and other languages.

License

MIT

Keywords

FAQs

Last updated on 14 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc