From e28739f8f1bcbbbb9f2d33bd94fb3acbbfa9dff9 Mon Sep 17 00:00:00 2001 From: tegwick Date: Thu, 21 May 2026 00:37:07 +0200 Subject: [PATCH] Fix Tailwind asset build dropping all utility classes in Docker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Dockerfile asset stage copied only static/src + vite.config.js, never the HTML templates. Tailwind v4 generates CSS by scanning source files for class usage, so with no templates present it emitted a stripped CSS with zero utility classes — breaking layout and ballooning SVG icons (w-5/h-5 no longer applied) on deployed builds. - main.css: add explicit @source directive for the templates dir so content detection no longer depends on the build CWD. - Dockerfile: copy vergabe_teilnahme/templates into the assets stage so the @source path resolves at build time. Co-Authored-By: Claude Opus 4.7 --- Dockerfile | 4 ++++ static/src/main.css | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index 23a06eb..e9ef483 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,10 @@ COPY package.json package-lock.json ./ RUN npm ci --no-audit --no-fund COPY vite.config.js ./ COPY static/src ./static/src +# Tailwind v4 scans these for utility-class usage at build time. They must be +# present or the generated CSS omits every utility class (broken layout, giant +# SVG icons). Paths mirror the @source directive in static/src/main.css. +COPY vergabe_teilnahme/templates ./vergabe_teilnahme/templates RUN npm run build # Output: /build/static/dist/main.css diff --git a/static/src/main.css b/static/src/main.css index b042e87..bc4d68e 100644 --- a/static/src/main.css +++ b/static/src/main.css @@ -1,5 +1,12 @@ @import "tailwindcss"; +/* Explicit content sources. Without these, Tailwind's automatic detection + depends on the build CWD finding the templates — which fails in the Docker + asset stage (it only copies static/src), producing a CSS with no utility + classes and badly oversized SVG icons. Keep these paths in sync with the + template dirs copied in the Dockerfile `assets` stage. */ +@source "../../vergabe_teilnahme/templates"; + @theme { --color-brand-50: #f0f4ff; --color-brand-100: #dce7ff;