N
N
nurise2015-05-09 13:35:06
css
nurise, 2015-05-09 13:35:06

How to pass an array of variables to postcss-simple-vars?

Let's say we have this code:

var colors = require('./src/config/colors');
var nav = require('./src/config/navbar');

var processors = [
  require('postcss-simple-vars')({ variables: [colors, nav] })
]

// colors.js
module.exports = {
  black: '#111',
  white: '#fff',
  gray: '#aaa',
  silver: '#ddd',
  primary: '#0074d9',
  success: '#2ecc40',
  warning: '#ff851b',
  danger: '#ff4136'
}

//navbar.js
module.exports = {
  navbar_height: '50px',
  navbar_bg: '$white'
}

In css, this no longer works (does not compile variables):
body {
  background-color: $white;
  color: $black;
}

.navbar {
  height: $navbar_height;
}

How to cook it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question