Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Latest commit

 

History

History
48 lines (39 loc) · 1022 Bytes

File metadata and controls

48 lines (39 loc) · 1022 Bytes

Transformation of SX Tailwind helpers into direct SX calls.

This has a positive impact on the final bundle size because the huge Tailwind definitions file can be omitted.

How does it work

import React from 'react';
+ import sx from '@adeira/sx';

export default function Example() {
  return (
    <button
-      sxt="bg-blue-500 text-white font-bold"
+      className={__styles('bg-blue-500', 'text-white', 'font-bold')}
      type="button"
    >
      Button
    </button>
  );
}

+ const __styles = sx.create({
+   'bg-blue-500': {
+     backgroundColor: '#4299e1',
+   },
+   'text-white': {
+     color: '#fff',
+   },
+   'font-bold': {
+     fontWeight: 700,
+   },
+ });

Install

yarn add --dev @adeira/babel-plugin-transform-sx-tailwind

Register in your Babel config (e.g. .babelrc):

{
  "plugins": ["@adeira/babel-plugin-transform-sx-tailwind"]
}