From a524997a2f4e2fb4b736d16b67a55b5c38146083 Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 16 Apr 2026 00:59:33 +0200 Subject: [PATCH] refactor(tailwind): centralize @source list in @mana/shared-tailwind/sources.css MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each consuming app was duplicating eight @source directives with hand- counted relative paths (../../../../../packages/…). The mana web app's were off-by-one for months before anyone noticed, silently disabling the scan for every shared-ui file. Tailwind v4 resolves @source paths relative to the CSS file that declares them, so we can drop the list once into packages/shared-tailwind/src/ sources.css. Consumer apps now just add one more @import next to themes.css: @import "tailwindcss"; @import "@mana/shared-tailwind/themes.css"; @import "@mana/shared-tailwind/sources.css"; New package.json export: "./sources.css". Drop the local paths from the mana web app's app.css. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/mana/apps/web/src/app.css | 12 +---------- packages/shared-tailwind/package.json | 3 ++- packages/shared-tailwind/src/sources.css | 26 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 packages/shared-tailwind/src/sources.css diff --git a/apps/mana/apps/web/src/app.css b/apps/mana/apps/web/src/app.css index 7a4694042..81e8cf61f 100644 --- a/apps/mana/apps/web/src/app.css +++ b/apps/mana/apps/web/src/app.css @@ -1,16 +1,6 @@ @import 'tailwindcss'; @import '@mana/shared-tailwind/themes.css'; - -/* Scan shared packages for Tailwind classes. - app.css is at apps/mana/apps/web/src/app.css — five levels below repo root. */ -@source "../../../../../packages/shared-ui/src"; -@source "../../../../../packages/shared-auth-ui/src"; -@source "../../../../../packages/shared-branding/src"; -@source "../../../../../packages/shared-theme-ui/src"; -@source "../../../../../packages/shared-theme-ui/src/components"; -@source "../../../../../packages/shared-theme-ui/src/pages"; -@source "../../../../../packages/subscriptions/src"; -@source "../../../../../packages/credits/src"; +@import '@mana/shared-tailwind/sources.css'; @layer base { :root { diff --git a/packages/shared-tailwind/package.json b/packages/shared-tailwind/package.json index ef45ddb1c..0b5174cd9 100644 --- a/packages/shared-tailwind/package.json +++ b/packages/shared-tailwind/package.json @@ -4,7 +4,8 @@ "private": true, "type": "module", "exports": { - "./themes.css": "./src/themes.css" + "./themes.css": "./src/themes.css", + "./sources.css": "./src/sources.css" }, "scripts": { "lint": "eslint ." diff --git a/packages/shared-tailwind/src/sources.css b/packages/shared-tailwind/src/sources.css new file mode 100644 index 000000000..f3b3375b5 --- /dev/null +++ b/packages/shared-tailwind/src/sources.css @@ -0,0 +1,26 @@ +/** + * Shared Tailwind source-scan list. + * + * Apps that consume our @mana/shared-* UI packages need Tailwind to scan + * those packages for utility classes (including arbitrary-value ones like + * `bg-[hsl(var(--color-muted))]`). Keeping the `@source` list in each app's + * app.css duplicates it and invites off-by-one path bugs — which is exactly + * what happened (`../../../../` instead of `../../../../../` meant Tailwind + * scanned nothing in shared packages, silently). + * + * Tailwind v4 resolves `@source` paths relative to the CSS file that + * declares them, so centralizing here means consumer apps just do: + * + * @import "tailwindcss"; + * @import "@mana/shared-tailwind/themes.css"; + * @import "@mana/shared-tailwind/sources.css"; + * + * and the paths Just Work regardless of how deep the consuming app lives. + */ + +@source "../../shared-ui/src"; +@source "../../shared-auth-ui/src"; +@source "../../shared-branding/src"; +@source "../../shared-theme-ui/src"; +@source "../../subscriptions/src"; +@source "../../credits/src";