From f924a8a73616bf5fa01c561c94bf0e0d1deb5f4f Mon Sep 17 00:00:00 2001 From: Anto Subash Date: Wed, 1 Apr 2026 14:02:41 +0200 Subject: [PATCH] Fix Docker deployment missing CSS and add favicon - Build Tailwind CSS explicitly in Dockerfile before dotnet publish so the output exists when MapStaticAssets evaluates the wwwroot manifest - Fix module CSS path in resolve-page.ts to use assembly name matching the _content/ static web asset convention - Add SVG favicon derived from the project logo --- .gitignore | 1 + Dockerfile | 16 ++++++---- .../SimpleModule.Client/src/resolve-page.ts | 11 ++++--- .../SimpleModule.Host/Components/App.razor | 1 + .../Components/InertiaShell.razor | 1 + .../SimpleModule.Host/wwwroot/favicon.svg | 30 +++++++++++++++++++ 6 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 template/SimpleModule.Host/wwwroot/favicon.svg diff --git a/.gitignore b/.gitignore index 058d5b3f..d8fc9043 100644 --- a/.gitignore +++ b/.gitignore @@ -420,6 +420,7 @@ modules/**/wwwroot/* # Tailwind CSS build output template/SimpleModule.Host/wwwroot/* +!template/SimpleModule.Host/wwwroot/favicon.svg # Tailwind CSS module scan directory template/SimpleModule.Host/Styles/_scan/ diff --git a/Dockerfile b/Dockerfile index 8167a1d6..99ba555e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,11 +108,17 @@ WORKDIR /src COPY . . -# Build all frontend workspaces -RUN npm run build - -# Publish the .NET application (MSBuild targets detect existing frontend -# outputs and only run TailwindBuild which needs Blazor SSR content) +# Build frontend: JS bundles then Tailwind CSS. +# Tailwind must run here so the output exists before dotnet publish +# evaluates wwwroot/ content — files generated during MSBuild targets +# are not picked up by the SDK's Content glob evaluation. +RUN npm run build \ + && npx @tailwindcss/cli \ + -i template/SimpleModule.Host/Styles/app.css \ + -o template/SimpleModule.Host/wwwroot/css/app.css \ + --minify + +# Publish the .NET application RUN dotnet publish template/SimpleModule.Host/SimpleModule.Host.csproj \ -c Release \ -o /app/publish \ diff --git a/packages/SimpleModule.Client/src/resolve-page.ts b/packages/SimpleModule.Client/src/resolve-page.ts index 5b93b593..1d7e4e1d 100644 --- a/packages/SimpleModule.Client/src/resolve-page.ts +++ b/packages/SimpleModule.Client/src/resolve-page.ts @@ -1,11 +1,10 @@ const loadedCss = new Set(); -function ensureModuleCss(moduleName: string, cacheBuster: string | undefined) { - if (loadedCss.has(moduleName)) return; - loadedCss.add(moduleName); +function ensureModuleCss(assemblyName: string, suffix: string) { + if (loadedCss.has(assemblyName)) return; + loadedCss.add(assemblyName); - const suffix = cacheBuster ? `?v=${cacheBuster}` : ''; - const href = `/_content/${moduleName}/${moduleName.toLowerCase()}.css${suffix}`; + const href = `/_content/${assemblyName}/${assemblyName.toLowerCase()}.css${suffix}`; const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = href; @@ -23,7 +22,7 @@ export async function resolvePage(name: string) { ?.content; const suffix = cacheBuster ? `?v=${cacheBuster}` : ''; - ensureModuleCss(moduleName, cacheBuster); + ensureModuleCss(assemblyName, suffix); const mod = await import( /* @vite-ignore */ diff --git a/template/SimpleModule.Host/Components/App.razor b/template/SimpleModule.Host/Components/App.razor index d0fb2301..32b937d3 100644 --- a/template/SimpleModule.Host/Components/App.razor +++ b/template/SimpleModule.Host/Components/App.razor @@ -8,6 +8,7 @@ + SimpleModule diff --git a/template/SimpleModule.Host/Components/InertiaShell.razor b/template/SimpleModule.Host/Components/InertiaShell.razor index f7597a70..c94e7116 100644 --- a/template/SimpleModule.Host/Components/InertiaShell.razor +++ b/template/SimpleModule.Host/Components/InertiaShell.razor @@ -12,6 +12,7 @@ + SimpleModule diff --git a/template/SimpleModule.Host/wwwroot/favicon.svg b/template/SimpleModule.Host/wwwroot/favicon.svg new file mode 100644 index 00000000..9f39c29b --- /dev/null +++ b/template/SimpleModule.Host/wwwroot/favicon.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +