andreypopp / styling

Create CSS modules with the full power of JavaScript
130 stars 4 forks source link

Question: example for using with a PostCSS plugin #6

Closed st32lthx closed 9 years ago

st32lthx commented 9 years ago

Was wondering if there is an example for using styling with a PostCSS plugin like postCSS-mixins. Would it have to be added as a webpack loader or is it possible to use the plugin features in *.style.js files?

Thanks !

andreypopp commented 9 years ago

Hi @aminmeyghani,

There's no example yet but you can use PostCSS plugin via postcss-loader (a bridge between Webpack and PostCSS) which you should configure right before css-loader kicks in.

I'd argue though that you don't need postcss-mixins when you use styling because you can use JavaScript to define mixins:

function icon(network, color) {
  return {
    color: color,
    background: `url(${network}.png)`
  }
}

export let style = styling({
  ...icon('twitter', 'red'),
  fontSize: 12
})