0.8.7 • Published 9 years ago

sass-vars-to-js v0.8.7

Weekly downloads
14
License
MIT
Repository
github
Last release
9 years ago

sass-vars-to-js

variables.scss to variables Object converter

npm version dependencies devDependecies

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.

Installation and Changes

Installation is straightforward:

$ npm install --save-dev sass-vars-to-js

Run tests:

$ npm test

Compile commonjs version with babel:

$ npm run build

Usage

There are two ways of requiring the module:

By default requiring module gets the commonjs version:

var converter = require('node_modules/sass-vars-to-js');

If you prefer (by whatever reasons) ES6 version, you can also try:

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

$color-brand-primary: #1711e2;
$color-brand-secondary: #fd0f79;

$footer-bg-color: $color-brand-primary;

colors.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

0.8.7

9 years ago

0.8.6

10 years ago

0.9.0

10 years ago

0.8.5

10 years ago

0.8.4

10 years ago

0.8.3

10 years ago

0.8.0

10 years ago

0.7.3

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago