Skip to content

Commit ed4bc4f

Browse files
authored
Fix Docker deployment missing CSS and add favicon (#43)
- 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
1 parent 7772aad commit ed4bc4f

6 files changed

Lines changed: 49 additions & 11 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ modules/**/wwwroot/*
420420

421421
# Tailwind CSS build output
422422
template/SimpleModule.Host/wwwroot/*
423+
!template/SimpleModule.Host/wwwroot/favicon.svg
423424

424425
# Tailwind CSS module scan directory
425426
template/SimpleModule.Host/Styles/_scan/

‎Dockerfile‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,17 @@ WORKDIR /src
108108

109109
COPY . .
110110

111-
# Build all frontend workspaces
112-
RUN npm run build
113-
114-
# Publish the .NET application (MSBuild targets detect existing frontend
115-
# outputs and only run TailwindBuild which needs Blazor SSR content)
111+
# Build frontend: JS bundles then Tailwind CSS.
112+
# Tailwind must run here so the output exists before dotnet publish
113+
# evaluates wwwroot/ content — files generated during MSBuild targets
114+
# are not picked up by the SDK's Content glob evaluation.
115+
RUN npm run build \
116+
&& npx @tailwindcss/cli \
117+
-i template/SimpleModule.Host/Styles/app.css \
118+
-o template/SimpleModule.Host/wwwroot/css/app.css \
119+
--minify
120+
121+
# Publish the .NET application
116122
RUN dotnet publish template/SimpleModule.Host/SimpleModule.Host.csproj \
117123
-c Release \
118124
-o /app/publish \

‎packages/SimpleModule.Client/src/resolve-page.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const loadedCss = new Set<string>();
22

3-
function ensureModuleCss(moduleName: string, cacheBuster: string | undefined) {
4-
if (loadedCss.has(moduleName)) return;
5-
loadedCss.add(moduleName);
3+
function ensureModuleCss(assemblyName: string, suffix: string) {
4+
if (loadedCss.has(assemblyName)) return;
5+
loadedCss.add(assemblyName);
66

7-
const suffix = cacheBuster ? `?v=${cacheBuster}` : '';
8-
const href = `/_content/${moduleName}/${moduleName.toLowerCase()}.css${suffix}`;
7+
const href = `/_content/${assemblyName}/${assemblyName.toLowerCase()}.css${suffix}`;
98
const link = document.createElement('link');
109
link.rel = 'stylesheet';
1110
link.href = href;
@@ -23,7 +22,7 @@ export async function resolvePage(name: string) {
2322
?.content;
2423
const suffix = cacheBuster ? `?v=${cacheBuster}` : '';
2524

26-
ensureModuleCss(moduleName, cacheBuster);
25+
ensureModuleCss(assemblyName, suffix);
2726

2827
const mod = await import(
2928
/* @vite-ignore */

‎template/SimpleModule.Host/Components/App.razor‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
99
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&family=JetBrains+Mono:wght@400;500;600&family=Sora:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
1010
<link rel="stylesheet" href="/css/app.css" />
11+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
1112
<title>SimpleModule</title>
1213
<HeadOutlet />
1314
<SimpleModule.Blazor.Components.DarkModeScript />

‎template/SimpleModule.Host/Components/InertiaShell.razor‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1313
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&family=JetBrains+Mono:wght@400;500;600&family=Sora:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
1414
<link rel="stylesheet" href="/css/app.css?v=@CacheBuster" />
15+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
1516
<title>SimpleModule</title>
1617
</HeadContent>
1718
<BodyPrefix>
Lines changed: 30 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)