ReeganExE / vite-plugin-twob-demo

Obfusates Tailwind classes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@vitetw/vite-plugin-twob

🚀 A Vite plugin that obfusates Tailwind classes.

  • Lightweight
  • Works with both SPA, SSG and SSR.
  • Works well with Remix and Astro.
  • Works well with mixed classes:
    • peer-checked:text-sky-500
    • group-hover/edit:text-gray-700
    • hidden peer-[.is-dirty]:peer-required:block
    • even:bg-slate-50 peer-[:nth-of-type(3)_&]:block odd:lg:bg-red-50 even:lg:bg-slate-300
  • Works with custom classes: btn-primary, ...

Note: This is just a document. I am using this plugin privately.

Setup

.npmrc

@vitetw:registry=https://npm.pkg.github.com
npm install @vitetw/vite-plugin-twob@beta

vite.config.js

import twobPlugin from '@vitetw/vite-plugin-twob'

export default defineConfig({
  // ...
  plugins: [twobPlugin()],
  // ...
})
{
  "scripts": {
    "build": "twob path/to/you-entrypoint-css.css && npm run your-build-cmd"
  }
}
  • Astro: twob node_modules/@astrojs/tailwind/base.css
# run build as usual
npm run build

About

Obfusates Tailwind classes