0.2.1 • Published 9 years ago
extract-scss-variables v0.2.1
Extract SCSS variables
An utility for extracting variables from .scss files.
Installation
npm install --save-dev extract-scss-variablesNode SASS must be installed, too.
If not present already, just install it with:
npm install --save-dev node-sassUsage
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.scssfile 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