@tailcloak/vite
v0.4.0
Published
Vite plugin that obfuscates Tailwind CSS v4 class names in production builds.
Maintainers
Readme
@tailcloak/vite
Vite plugin that obfuscates Tailwind CSS v4 class names in production builds. Each class string becomes one short, prefixed name.
Requires Vite 6+, @tailwindcss/vite 4.1+ and Node.js 20.19+. Works with any framework whose components compile to JS (React, Preact, Solid, Qwik, …). Templates in .vue, .svelte and .astro files are not rewritten yet.
Setup
npm i -D @tailcloak/vite
npx tailcloak initinit writes a tailcloak.config.ts with a random secret seed at your repository root. Commit it. Production builds fail without a seed.
// vite.config.ts
import tailcloak from "@tailcloak/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tailwindcss(), tailcloak()],
});vite build obfuscates; vite dev is left untouched unless you pass enabled: true.
Options
Set options in tailcloak.config.ts, or inline: tailcloak({ prefix: "tc_" }).
See tailcloak for every option, what gets rewritten, and the limitations.
How it works
- A
pretransform renames classes in JS/TS/JSX modules outsidenode_modules, before JSX and TypeScript are compiled. - A normal-phase transform renames the utilities in the stylesheet
@tailwindcss/vitegenerated, before Vite bundles and minifies it.
License
MIT
