https://github.com/devtin/sass-vars-to-json
https://github.com/devtin/sass-vars-to-json
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devtin/sass-vars-to-json
- Owner: devtin
- Created: 2018-04-30T10:30:09.000Z (almost 8 years ago)
- Default Branch: development
- Last Pushed: 2023-03-05T10:41:11.000Z (about 3 years ago)
- Last Synced: 2025-09-01T03:46:06.829Z (7 months ago)
- Language: SCSS
- Size: 607 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# sass-vars-to-json
Converts sass variables into JSON objects.
## Installation
``` bash
$ npm install sass-vars-to-json
```
## Usage
example.scss
``` scss
$toolbarHeight: 60px;
$toolbarFont: "Roboto-Slab", "Times New Roman", serif;
$toolbarBoxShadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
$toolbarBgColor: rgba(#e7e7e7, .5);
$toolbarIsFixed: true;
$toolbarColor: null;
$palette: (
white: #e7e7e7,
orange: #fc0
);
$theme: (
font: "Arial, sans-serif",
head-background: map-get($palette, orange)
);
```
index.js
``` js
const sassVarsToJSON = require('sass-vars-to-json')
sassVarsToJSON('./example.scss'/*, compileOptions, extractOptions */)
.then(vars => {
console.log(vars.$toolbarHeight); // => '60px'
console.log(vars.$toolbarFont); // => 'Roboto-Slab, Times New Roman, serif'
console.log(vars.$toolbarBoxShadow); // => '10px 10px 5px 0px rgba(0, 0, 0, 0.75)'
console.log(vars.$toolbarBgColor); // => 'rgba(231, 231, 231, 0.5)'
console.log(vars.$toolbarIsFixed); // => true
console.log(vars.$toolbarColor); // => null
console.log(vars.$palette.white); // => '#e7e7e7'
console.log(vars.$theme['head-background']); // => '#ffcc00'
console.log(vars.$theme.font); // => 'Arial, sans-serif'
});
```
## License
MIT