Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
sass-graph
Advanced tools
The sass-graph npm package is a utility that helps in analyzing the dependencies of Sass files in a project. It parses Sass files to find all the `@import` statements and constructs a graph of the relationships between files. This is particularly useful for understanding and managing complex stylesheets structures in large projects.
Parsing a directory of Sass files
This feature allows you to parse an entire directory of Sass files to create a graph representing the dependencies between them.
const sassGraph = require('sass-graph');
const graph = sassGraph.parseDir('path/to/sass/files');
Finding dependencies of a single Sass file
This feature is used to find all the files that depend on a single Sass file, which can be useful for understanding the impact of changes to that file.
const sassGraph = require('sass-graph');
const graph = sassGraph.parseFile('path/to/sass/file.scss', options);
const dependencies = graph.index['path/to/sass/file.scss'].importedBy;
Watching a directory of Sass files for changes
This feature sets up a watcher on a directory of Sass files and triggers a callback with the changed files when a change is detected.
const sassGraph = require('sass-graph');
const graph = sassGraph.parseDir('path/to/sass/files');
sassGraph.watch('path/to/sass/files', options, (changedFiles) => {
console.log('Files changed:', changedFiles);
});
PostCSS is a tool for transforming CSS with JavaScript plugins. While it is not limited to Sass, it can be used to analyze and manipulate CSS dependencies, similar to how sass-graph analyzes Sass dependencies.
node-sass-magic-importer is a custom importer for node-sass that adds additional features to the standard Sass `@import` rule. It provides functionalities that can help manage dependencies, but it is more focused on extending the import capabilities rather than analyzing the dependency graph.
Stylelint is a linter for stylesheets that can be used to enforce consistent conventions and avoid errors in stylesheets. It does not construct a dependency graph like sass-graph, but it can be used to analyze and lint the structure of Sass files.
Parses sass and exposes a graph of dependencies
Install with npm
npm install --save-dev sass-graph
Usage as a Node library:
$ node
> var sassGraph = require('./sass-graph');
undefined
> sassGraph.parseDir('tests/fixtures');
{ index: {,
'tests/fixtures/a.scss': {
imports: ['b.scss'],
importedBy: [],
},
'tests/fixtures/b.scss': {
imports: ['_c.scss'],
importedBy: ['a.scss'],
},
'tests/fixtures/_c.scss': {
imports: [],
importedBy: ['b/scss'],
},
}}
Usage as a command line tool:
The command line tool will parse a graph and then either display ancestors, descendents or both.
$ ./bin/sassgraph tests/fixtures tests/fixtures/a.scss -d
tests/fixtures/a.scss
tests/fixtures/b.scss
tests/fixtures/_c.scss
You can run the tests by executing the following commands:
npm install
npm test
Sass graph was originally written by Lachlan Donald. It is now maintained by Michael Mifsud.
MIT
FAQs
Parse sass files and extract a graph of imports
The npm package sass-graph receives a total of 1,174,306 weekly downloads. As such, sass-graph popularity was classified as popular.
We found that sass-graph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.