Simple and useful utility for Tailwind CSS.
npm i -D @mkx419/tx @mkx419/rollup-plugin-tx
npm i -D @mkx419/tx @mkx419/vite-plugin-tx
pnpm add -D @mkx419/tx @mkx419/rollup-plugin-tx
pnpm add -D @mkx419/tx @mkx419/vite-plugin-tx
// rollup.config.js
import { txPlugin } from "@mkx419/rollup-plugin-tx";
export default {
plugins: [txPlugin()],
};
// vite.config.ts
import { txPlugin } from "@mkx419/vite-plugin-tx";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [txPlugin()],
});
{
"tailwindCSS.experimental.classRegex": [["t[xmv]\\(([^)]*)\\)", "[\"'`]([^\"'`]*)[\"'`]"]]
}
import { tx } from "@mkx419/tx";
tx("bg-black", "text-white", true && "font-bold");
to
`bg-black text-white${true ? ` ${"font-bold"}` : ""}`;
import { tx } from "@mkx419/tx";
tm("hover:", tx("bg-black", "text-white"));
to
"hover:bg-black hover:text-white";
import { tv } from "@mkx419/tx";
const size = tv({
sm: "h-4",
md: "h-6",
lg: "h-8",
});
size("sm");
to
import { tv } from "@mkx419/tx";
const size = tv({
sm: "h-4",
md: "h-6",
lg: "h-8",
});
size("sm");