bradlc / babel-plugin-tailwind-components

Use Tailwind with any CSS-in-JS library
MIT License
332 stars 25 forks source link

Difference with babel-plugin-tailwind #4

Open muhajirdev opened 6 years ago

muhajirdev commented 6 years ago

What's the difference with https://github.com/andrewdelprete/babel-plugin-tailwind ?

josiahdahl commented 6 years ago

@muhajirframe That plugin had the last update 6 months ago, this one 13 days ago. It's more up-to-date with the latest version of Tailwind.

bradlc commented 6 years ago

Hey @muhajirframe

There are a few notable differences:

bradlc commented 6 years ago

The two plugins have fundamentally different approaches. The other one takes a compiled Tailwind CSS file and creates a list of class names from that, whereas this plugin does not require a CSS file at all, it works directly from your Tailwind config.

Here’s how this plugin transforms your code in development:

import tw from 'tailwind.macro'
let styles = tw`w-1/2`

// ↓↓↓↓↓↓↓↓

import _tailwind from './path/to/your/tailwind.js'
let styles = {
  width: _tailwind.widths['1/2']
}

And when run in production (NODE_ENV=production):

import tw from 'tailwind.macro'
let styles = tw`w-1/2`

// ↓↓↓↓↓↓↓↓

let styles = {
  width: '50%'
}
muhajirdev commented 6 years ago

Woah, thank you very much @bradlc @josiahdahl .

Love what you do.

About this plugin doesn’t support Tailwind plugins. Is it intentionally by design, or you're still working on this?

bradlc commented 6 years ago

No plans to support plugins right now. Not sure how feasible it is.

Since you’re in CSS-in-JS-land anyway, you can write your own "plugins" in JavaScript, or use something like polished

bradlc commented 6 years ago

Thinking about it some more, I think it might be doable! I will have a look when I get chance.

muhajirdev commented 6 years ago

Ah, got it.

andrewdelprete commented 6 years ago

Hey awesome job on the macro approach. I wrote babel-plugin-tailwind as my first experiment with doing the AST stuff. I do plan on making some adjustments in the near future to update it with the latest version of Tailwind, but I think your approach is spot on. 🙌🏻 // @bradlc