5.1.0 • Published 6 months ago

sass-graph-ts v5.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Sass-graph-ts

Test npm

Fork of https://github.com/xzyfer/sass-graph. Rewritten in TypeScript, with updated dependencies and support for @use and @forward.

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

Install

npm install --save-dev sass-graph-ts

Usage

Usage as a Node library:

import { SassGraph } from 'sass-graph-ts';

const graph: SassGraph = SassGraph.parseDir('/home/username/project/styles', {
  extensions: ['scss'],
});

Usage as a command line tool:

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

Run sass-graph --help for more details.

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.

resolver

Type: (string) => string | false; Default: undefined

Custom resolver for imports, return false to run default resolver. Might be useful for custom imports, or pkg: scheme.

Example

import { SassGraph } from 'sass-graph-ts';

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. It is now maintained by Michael Mifsud. TS rewrite by WandererXII.

License

MIT

5.1.0

6 months ago

5.0.0

8 months ago