Tailwind CSS plugin
The plugin generates CSS from className strings in published page data. It does not scan component
source files. Keep static component styles in your app’s normal Tailwind build.
Setup
Install the plugin:
npm install @oberoncms/plugin-tailwindImport it in oberon/config.ts:
import { plugin as tailwindPlugin } from "@oberoncms/plugin-tailwind"Add tailwindPlugin before the framework and auth plugins. See Configuration
for plugin order. The installer does not add this plugin automatically.
Generated styles
Bootstrap and page updates collect classes from all published pages. The plugin stores CSS and its
hash through the Adapter’s key-value methods. The state uses namespace @oberoncms/plugin-tailwind
and key state.
Read the active hash in your server render route:
import { adapter } from "@/oberon/adapter"
async function getStylesheet() {
const state = await adapter.getKV({
namespace: "@oberoncms/plugin-tailwind",
key: "state",
})
if (
typeof state !== "object" ||
state === null ||
!("activeHash" in state) ||
typeof state.activeHash !== "string"
) {
return null
}
return `/cms/api/tailwind/${encodeURIComponent(state.activeHash)}.css`
}Render the URL as a stylesheet link when it is not null:
<link rel="stylesheet" href={href} precedence="oberon-dynamic" />Mount the CMS API handler to serve the CSS. Successful responses use a one-year cache lifetime and immutable URLs. The plugin regenerates CSS when the class list changes or the stored asset is missing.
The hash identifies the generated CSS. Text-only Page edits do not change the stylesheet URL. The Plugin keeps previous stylesheets available after styles change or are cleared, so cached Pages can still load their styles without invalidating other Pages.