Skip to content

@hamur/tailwind

The first-party Tailwind module. It compiles Tailwind v4 with compile of @tailwindcss/node and scans your sources with Scanner of @tailwindcss/oxide, the two packages that @tailwindcss/vite and @tailwindcss/postcss are hosts over. It uses no PostCSS and has no options. The Styling page shows it with a sample; install it with the three packages it needs, as peers, and add it to modules.

sh
bun add -d tailwindcss @tailwindcss/node @tailwindcss/oxide @hamur/tailwind
ts
// hamur.config.ts
import tailwind from "@hamur/tailwind"

export default defineConfig({
  modules: [tailwind],
})
tsx
// app/app.tsx
import { Outlet } from "@hamur/adapter-react"
import "./styles/tailwind.css"

export default function App() {
  return <Outlet />
}

default

The module, as defineModule({ meta: { name: "tailwind" } }). Its setup checks the installed tailwindcss and adds the Bun plugin hamur-tailwind to the client and server builds and to both dev builds.

  • The version. tailwindcss is read from the app's root at setup. A major other than 4 fails the build with @hamur/tailwind needs tailwindcss 4; found 3.4.17; none installed fails it with @hamur/tailwind needs "tailwindcss" installed in the app. @tailwindcss/node and @tailwindcss/oxide are imported from the app's root when the first stylesheet loads; without one, the build fails with @hamur/tailwind needs "@tailwindcss/oxide" installed in the app.
  • Which files. A .css file that imports tailwindcss or uses @apply, @theme, @source, @utility, @variant, @custom-variant, @plugin or @config. Every other .css file is loaded by Bun as it is, byte for byte.
  • The output. The compiled CSS goes back to Bun, which bundles and minifies it, so the module runs no optimize pass. The server build carries no CSS.
  • The sources. The compiler names them: @source and @source not in the CSS, and the app's root by default, without the build and output directories.
  • In hamur dev. A change to a source file that adds a class builds the stylesheet again and the page takes it with no restart and no reload. A class that an edit removes stays until the stylesheet changes or hamur dev restarts.