martinandert / babel-plugin-css-in-js

A plugin for Babel v6 which transforms inline styles defined in JavaScript modules into class names so they become available to, e.g. the `className` prop of React elements. While transforming, the plugin processes all JavaScript style definitions found and bundles them up into a CSS file, ready to be requested from your web server.
MIT License
298 stars 11 forks source link

Not Getting Expressions To Work AssertionError #8

Closed ryantallmadge closed 8 years ago

ryantallmadge commented 8 years ago

Im getting and error:

AssertionError: /PATH/TO/PAGE : invalid value expression type while parsing file /PATH/TO/SAME/PAGE

I have a simple CSS:

main.js

var colors = require('../styles/colors'); var pageCss = cssInJS({ 'default' : { 'backgroundColor' : colors.greys._1 } });

colors.js

var colors = { 'greys' : { _1 : '#F2F5F8' } }; module.exports = colors;

martinandert commented 8 years ago

Yeah this is because nothing is actually required and compiled when babel does its transformation magic. However, what you trying to do can be achieved with the context option. See also the section "Expressions in Style Rules" in the README.

If you have any further question, feel free to ask.