![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
postcss-bs-tailwind
Advanced tools
A PostCSS plugin for generating Tailwind CSS types for BuckleScript/ReasonML
A PostCSS plugin for generating ReasonML variables that correspond to Tailwind CSS classnames.
This plugin generates a Tailwind.re
module for you that contains a binding for each and every Tailwind class in your CSS. So, instead of relying on strings in your code (which can be prone to typos), you get the safety (and the auto-complete) of a variable! And, thanks to BuckleScript's [@bs.inline]
directive, the bindings have zero runtime cost! They complile to plain strings!
This codegen tool works best when you're using re-classnames, which is a ReasonML implementation of the popular classnames library for composing classes into a string you can pass to the className
prop on a DOM node. The examples bellow assume you've followed re-classname's installation instructions.
npm install postcss-bs-tailwind re-classnames
# or
yarn add postcss-bs-tailwind re-classnames
Then, update your PostCSS config to look something like this:
const tailwindcss = require("tailwindcss");
const reason = require("postcss-bs-tailwind");
module.exports = {
plugins: [
tailwindcss("./tailwind.config.js"),
require("autoprefixer"),
reason({ modulePath: "./bindings/Tailwind.re" })
]
};
Important: Make sure this plugin appears after your tailwindcss
plugin, preferably last in the list.
The modulePath
config value is required, and denotes the name/location where you'd like the generated module. Now, when you run PostCSS, you'll end up with a Reason module that looks like this:
// ...
[@bs.inline] let bg_cyan_050 = "bg-cyan-050";
[@bs.inline] let bg_cyan_100 = "bg-cyan-100";
[@bs.inline] let bg_cyan_200 = "bg-cyan-200";
[@bs.inline] let bg_cyan_300 = "bg-cyan-300";
// ...
So now, in your ReasonReact code, you can do:
open Tailwind;
[@react.component]
let make = () => {
<button className=Cn.make([bg_cyan_300])> "Cyan Button"->React.string </button>
};
Tailwind's default naming scheme isn't compatible with Reason's syntax, so each name gets changed a little:
Tailwind Class | Reason Variable | Naming Rule |
---|---|---|
bg-blue-100 | bg_blue_100 | - gets changed to _ |
focus:bg-blue-100 | focus__bg_blue_050 | : gets changed to __ |
-m-1 | neg_m_1 | - as a prefix gets changed to neg_ |
w-1/2 | w_one_half | 1/2 gets changed to one_half (other fractions get replaced with their text representation) |
Don't worry - the Reason varaible is only a placeholder for the actual string value! When your Reason code is compliled to JS, the original Tailwind string will be right where you expect it!
No worries! This plugin works by parsing the CSS after Tailwind CSS is generated. It walks through each class definition in your CSS code and transforms the class' name into something that's Reason-friendly. So, any special classes you've got (from Tailwind plugins or custom config) should get picked up just fine. That said, there could be some naming edge cases that aren't handled as of yet. Feel free to open an issue if you bump into one!
FAQs
A PostCSS plugin for generating Tailwind CSS types for BuckleScript/ReasonML
The npm package postcss-bs-tailwind receives a total of 1 weekly downloads. As such, postcss-bs-tailwind popularity was classified as not popular.
We found that postcss-bs-tailwind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.