0.2.1 • Published 7 years ago

extract-scss-variables v0.2.1

Weekly downloads
21
License
ISC
Repository
github
Last release
7 years ago

Extract SCSS variables

Build Status Build status Coverage Status NPM Version

An utility for extracting variables from .scss files.

Installation

npm install --save-dev extract-scss-variables

Node SASS must be installed, too.
If not present already, just install it with:

npm install --save-dev node-sass

Usage

var extractScssVariables = require('extract-scss-variables');
var variables = extractScssVariables({
  entryPoint: entryPath,
  files: filePaths,
  sassOptions: { 
    includePaths: includePaths,
  },
});

Internally variable declarations are extracted and their value is appended at the end of a copy of the provided entryPath file.
Using the "content:" trick:

#test {
  content: "#{$extracted-value}";
}

and compiling the entryPath copy with node-sass, the computed values could be easily extracted.

CLI

Running the CLI version will produce a JSON file containing all extracted variables.

  • <entry-point>: SCSS entry point
  • -f, --file <path>: path to a .scss file from where to extract the variables. It can occur multiple times
  • -c, --sass-config: JSON string or path to a JSON file with node-sass additional config
  • -o, --output <path>: path where to save the JSON output

For example:

extract-scss-values bundle.scss -f _globals.scss -f _settings.scss
0.2.1

7 years ago

0.2.0

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago