https://github.com/xop/sass-vars-to-js
variables.scss to [variables Object] converter
https://github.com/xop/sass-vars-to-js
Last synced: 10 days ago
JSON representation
variables.scss to [variables Object] converter
- Host: GitHub
- URL: https://github.com/xop/sass-vars-to-js
- Owner: XOP
- License: mit
- Created: 2016-04-02T10:18:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-05T02:56:42.000Z (almost 8 years ago)
- Last Synced: 2024-06-21T16:58:45.921Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sass-vars-to-js
> variables.scss to [variables Object] converter
[](https://badge.fury.io/js/sass-vars-to-js) [](https://david-dm.org/XOP/sass-vars-to-js) [](https://david-dm.org/XOP/sass-vars-to-js#info=devDependencies)
## About
Sometimes you just need to use SASS variables in JS without incorporating complex logic.
And no CSS-module-specific logic behind this.### Important
**Not actively maintained**
If you want to cooperate or even adopt the project, please [let me know](mailto:[email protected]).
## Installation and Changes
Installation is straightforward:
```
$ npm install --save-dev sass-vars-to-js
```Run tests:
```
$ npm test
```Compile commonjs version with [babel](https://babeljs.io/):
```
$ npm run build
```## Usage
There are two ways of requiring the module:
By default requiring module gets the commonjs version:
```js
var converter = require('node_modules/sass-vars-to-js');
```If you prefer (by whatever reasons) ES6 version, you can also try:
```js
import converter from 'node_modules/sass-vars-to-js/src'
```Function accepts string - path to a SASS file, containing variables.
It returns the object, very similar to the variable definition syntax:**variables.scss**
```scss
$color-brand-primary: #1711e2;
$color-brand-secondary: #fd0f79;$footer-bg-color: $color-brand-primary;
```**colors.js**
```js
import converter from 'sass-vars-to-js';const variables = converter(path/to/variables.scss);
// {
// 'color-brand-primary': '#1711e2',
// 'color-brand-secondary': '#fd0f79',
// 'footer-bg-color': '#1711e2'
// }const colors = {
brandPrimary: variables['color-brand-primary'],
brandSecondary: variables['color-brand-secondary']
};
```## Limits of use
Please be aware of current version (0.x - 1.x) limitations:
- maps and other complex stuff is not supported
- sass expressions not supported
- sass functions not supported## License: [MIT](LICENSE)