GitXplorerGitXplorer
E

extract-scss-variables

public
3 stars
0 forks
2 issues

Commits

List of commits on branch master.
Verified
55132da84a8bf4a5149c4732f4b8be7533ee39c7

Merge pull request #4 from DanielGibbsNZ/feature/support-node-8

EEnoahNetzach committed 7 years ago
Unverified
d2c32f7b0749c4affb5b649434a0c2b128378729

Support Node >= 4

DDanielGibbsNZ committed 7 years ago
Unverified
24485cc8e1942ba36c9b645de28dff5bc802fd05

Support Node 8

DDanielGibbsNZ committed 7 years ago
Unverified
18a7990dd9f097a3d3e7e0fd20daddfe060d3d97

feat(): build the bundle with rollup, add support for es modules

EEnoahNetzach committed 7 years ago
Unverified
a3e644eb84b39c6a6b4e76cb978d009f5f123345

feat(): rewrite everything in es6

EEnoahNetzach committed 7 years ago
Unverified
7a20fa86604f4ef963441c739f7b0992c4a36292

chore(): bump npm version

EEnoahNetzach committed 7 years ago

README

The README file for this repository.

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