# sass-graph

> Parse sass files and extract a graph of imports

Latest version **4.0.1** (published 2022-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install sass-graph
pnpm add sass-graph
yarn add sass-graph
bun add sass-graph
```

Provides the command `sassgraph`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2022-09-01 |
| First published | 2014-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/sass-graph) |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 4 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 76 |
| Author | xzyfer |
| Maintainers | lox, xzyfer |
| Keywords | sass, graph |

## Links

- npm: https://www.npmjs.com/package/sass-graph
- Repository: https://github.com/xzyfer/sass-graph
- Homepage: https://github.com/xzyfer/sass-graph#readme
- Issues: https://github.com/xzyfer/sass-graph/issues
- npm.io page: https://npm.io/package/sass-graph

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^7.0.0
- [yargs](https://npm.io/package/yargs.md) ^17.2.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [scss-tokenizer](https://npm.io/package/scss-tokenizer.md) ^0.4.3

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2022-09-01
- 2.2.2 (beta) — 2017-04-29
- 4.0.0 — 2021-12-27
- 3.0.5 — 2020-05-04
- 2.2.6 — 2020-05-04
- 2.2.5 — 2020-05-04
- 3.0.4 — 2019-02-21
- 3.0.3 — 2018-10-16
- 3.0.2 — 2018-10-12
- 3.0.1 — 2018-10-10
- 3.0.0 — 2018-04-16
- 2.2.4 — 2017-05-17
- 2.2.3 — 2017-05-12
- 2.2.1 — 2017-04-29
- 2.2.0 — 2017-04-28
- … 15 more at https://npm.io/package/sass-graph/versions

## README

# Sass Graph

Parses Sass files in a directory and exposes a graph of dependencies

[![Build Status](https://travis-ci.org/xzyfer/sass-graph.svg?branch=master)](https://travis-ci.org/xzyfer/sass-graph)
[![Coverage Status](https://coveralls.io/repos/github/xzyfer/sass-graph/badge.svg?branch=master)](https://coveralls.io/github/xzyfer/sass-graph?branch=master)
[![npm version](https://badge.fury.io/js/sass-graph.svg)](http://badge.fury.io/js/sass-graph)
[![Dependency Status](https://david-dm.org/xzyfer/sass-graph.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph)
[![devDependency Status](https://david-dm.org/xzyfer/sass-graph/dev-status.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph#info=devDependencies)

## Install

Install with [npm](https://npmjs.org/package/sass-graph)

```
npm install --save-dev sass-graph
```

## Usage

Usage as a Node library:

```js
var sassGraph = require('./sass-graph');
```

Usage as a command line tool:

The command line tool will parse a graph and then either display ancestors, descendents or both.

```
$ ./bin/sassgraph --help
Usage: bin/sassgraph <command> [options] <dir> [file]

Commands:
  ancestors    Output the ancestors
  descendents  Output the descendents

Options:
  -I, --load-path   Add directories to the sass load path
  -e, --extensions  File extensions to include in the graph
  -j, --json        Output the index in json
  -h, --help        Show help
  -v, --version     Show version number

Examples:
  ./bin/sassgraph descendents test/fixtures test/fixtures/a.scss
  /path/to/test/fixtures/b.scss
  /path/to/test/fixtures/_c.scss
```

## API

#### parseDir

Parses a directory and builds a dependency graph of all requested file extensions.

#### parseFile

Parses a file and builds its dependency graph.

## Options

#### loadPaths

Type: `Array`
Default: `[process.cwd]`

Directories to use when resolved `@import` directives.

#### extensions

Type: `Array`
Default: `['scss', 'sass']`

File types to be parsed.

#### follow

Type: `Boolean`
Default: `false`

Follow symbolic links.

#### exclude

Type: `RegExp`
Default: `undefined`

Exclude files matching regular expression.

## Example

```js
var sassGraph = require('./sass-graph');
console.log(sassGraph.parseDir('test/fixtures'));

//{ index: {,
//    '/path/to/test/fixtures/a.scss': {
//        imports: ['b.scss'],
//        importedBy: [],
//    },
//    '/path/to/test/fixtures/b.scss': {
//        imports: ['_c.scss'],
//        importedBy: ['a.scss'],
//    },
//    '/path/to/test/fixtures/_c.scss': {
//        imports: [],
//        importedBy: ['b/scss'],
//    },
//}}
```

## Running Mocha tests

You can run the tests by executing the following commands:

```
npm install
npm test
```

## Authors

Sass graph was originally written by [Lachlan Donald](http://lachlan.me).
It is now maintained by [Michael Mifsud](http://twitter.com/xzyfer).

## License

MIT

---
_Source: https://npm.io/package/sass-graph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
