sass-graph

Parse sass files and extract a graph of imports

MIT 30 个版本
安装
npm install sass-graph
yarn add sass-graph
pnpm add sass-graph
bun add sass-graph
README

Sass Graph

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

Build Status Coverage Status npm version Dependency Status devDependency Status

Install

Install with npm

npm install --save-dev sass-graph

Usage

Usage as a Node library:

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

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

License

MIT

版本列表
4.0.1 2022-09-01
4.0.0 2021-12-27
3.0.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.6 2020-05-04
2.2.5 2020-05-04
2.2.4 2017-05-17
2.2.3 2017-05-12
2.2.2 2017-04-29
2.2.1 2017-04-29
2.2.0 2017-04-28
2.1.2 2016-06-15
2.1.1 2016-02-04
2.1.0 2016-01-29
2.0.1 2015-08-12
2.0.0 2015-05-04
1.3.0 2015-04-13
1.2.0 2015-03-22
1.1.0 2015-03-18
1.0.3 2015-02-02
1.0.2 2015-02-02
1.0.1 2015-01-15
1.0.0 2015-01-15
0.1.2 2014-04-18
0.1.1 2014-04-18
0.1.0 2014-02-20