Skip to content

postcss-tailwind-v3 work in progress ​

A PostCSS plugin from @frontpack/widget-build-tools that runs Tailwind CSS v3 with an explicit config, resolved against your widget's own installed version.

Do you need this? ​

  • ✅ Your widget uses Tailwind v3 and is lives inside a (Nx) monorepo with other apps that also use Tailwind.
  • ❌ Skip this if your widget uses Tailwind CSS v4 — use @tailwindcss/postcss instead, it auto-discovers its config and needs no wrapper.

What problem does it solve? ​

Tailwind CSS v4 ships its own first-party PostCSS plugin (@tailwindcss/postcss) that auto-discovers its config relative to the stylesheet being processed. Tailwind CSS v3 doesn't work that way — it must be invoked as a classic PostCSS plugin, and it needs an explicit config file or object to know which content to scan and which theme to use.

On top of that, widgets live in an Nx monorepo where tailwindcss is installed both at the workspace root (often a newer major version, for other packages) and inside the widget's own node_modules (the version the widget actually targets). A naive require('tailwindcss') from a shared build-tools package resolves relative to that package's own location in the node_modules tree — not the widget's — so it can easily pick up the wrong major version and fail to build, or worse, silently produce different CSS.

How to install it ​

Add @frontpack/widget-build-tools as dependencies of your widget package:

bash
npm install --save @frontpack/widget-build-tools

How to use it ​

Reference the plugin in your widget's postcss.config.json, passing either a configPath or an inline config object:

json
// postcss.config.json
{
  "plugins": {
    "@frontpack/widget-build-tools/postcss-tailwind-v3": {
      "configPath": "packages/my-widget/tailwind.config.js"
    }
  }
}

TIP

configPath is resolved relative to process.cwd() — typically the monorepo workspace root when the build runs via Nx, matching the other workspace-root-relative paths already used in project.json files.