fix: add public dir with favicon.png for webui dumb:// URLs
- commit
- 3655ce7aa5921f25e5426b0ab8b9ed111d813ef6
- author
- brice · · 2025-12-28 16:59 UTC
- parent
- c7f6c5b
- signature
- unsigned
2 files · +21 -0
A webui/public/favicon.png +0 -0 binary file: no text diff
binary file: no text diff
M webui/vite.config.ts +21 -0
| @@ -2,6 +2,7 @@ import { defineConfig } from "vite"; | |||
| 2 | 2 | import { svelte } from "@sveltejs/vite-plugin-svelte"; | |
| 3 | 3 | import { resolve } from "path"; | |
| 4 | 4 | import { pageGenerator } from "./vite-plugin-pages"; | |
| 5 | + | import { copyFileSync, existsSync, mkdirSync } from "fs"; | |
| 5 | 6 | ||
| 6 | 7 | // Page configurations for dumb:// protocol pages | |
| 7 | 8 | const pages = { | |
| @@ -46,6 +47,20 @@ const pages = { | |||
| 46 | 47 | // Get page from VITE_PAGE env var, default to building all | |
| 47 | 48 | const targetPage = process.env.VITE_PAGE as keyof typeof pages | undefined; | |
| 48 | 49 | ||
| 50 | + | // Copy public assets to output directory | |
| 51 | + | function copyPublicAssets() { | |
| 52 | + | const outDir = resolve(__dirname, "../assets/webui"); | |
| 53 | + | const publicDir = resolve(__dirname, "public"); | |
| 54 | + | if (!existsSync(outDir)) { | |
| 55 | + | mkdirSync(outDir, { recursive: true }); | |
| 56 | + | } | |
| 57 | + | // Copy favicon.png for dumb:// URL favicons | |
| 58 | + | const faviconSrc = resolve(publicDir, "favicon.png"); | |
| 59 | + | if (existsSync(faviconSrc)) { | |
| 60 | + | copyFileSync(faviconSrc, resolve(outDir, "favicon.png")); | |
| 61 | + | } | |
| 62 | + | } | |
| 63 | + | ||
| 49 | 64 | // Build single page config | |
| 50 | 65 | function buildPageConfig(pageName: keyof typeof pages) { | |
| 51 | 66 | const page = pages[pageName]; | |
| @@ -55,6 +70,12 @@ function buildPageConfig(pageName: keyof typeof pages) { | |||
| 55 | 70 | emitCss: false, // Inline component CSS for shadow DOM compatibility | |
| 56 | 71 | }), | |
| 57 | 72 | pageGenerator([page.html]), | |
| 73 | + | { | |
| 74 | + | name: "copy-public-assets", | |
| 75 | + | closeBundle() { | |
| 76 | + | copyPublicAssets(); | |
| 77 | + | }, | |
| 78 | + | }, | |
| 58 | 79 | ], | |
| 59 | 80 | build: { | |
| 60 | 81 | rollupOptions: { | |
| @@ -2,6 +2,7 @@ import { defineConfig } from "vite"; | |||||
| 2 | import { svelte } from "@sveltejs/vite-plugin-svelte"; | 2 | import { svelte } from "@sveltejs/vite-plugin-svelte"; | ||
| 3 | import { resolve } from "path"; | 3 | import { resolve } from "path"; | ||
| 4 | import { pageGenerator } from "./vite-plugin-pages"; | 4 | import { pageGenerator } from "./vite-plugin-pages"; | ||
| 5 | + | import { copyFileSync, existsSync, mkdirSync } from "fs"; | |||
| 5 | 6 | ||||
| 6 | // Page configurations for dumb:// protocol pages | 7 | // Page configurations for dumb:// protocol pages | ||
| 7 | const pages = { | 8 | const pages = { | ||
| @@ -46,6 +47,20 @@ const pages = { | |||||
| 46 | // Get page from VITE_PAGE env var, default to building all | 47 | // Get page from VITE_PAGE env var, default to building all | ||
| 47 | const targetPage = process.env.VITE_PAGE as keyof typeof pages | undefined; | 48 | const targetPage = process.env.VITE_PAGE as keyof typeof pages | undefined; | ||
| 48 | 49 | ||||
| 50 | + | // Copy public assets to output directory | |||
| 51 | + | function copyPublicAssets() { | |||
| 52 | + | const outDir = resolve(__dirname, "../assets/webui"); | |||
| 53 | + | const publicDir = resolve(__dirname, "public"); | |||
| 54 | + | if (!existsSync(outDir)) { | |||
| 55 | + | mkdirSync(outDir, { recursive: true }); | |||
| 56 | + | } | |||
| 57 | + | // Copy favicon.png for dumb:// URL favicons | |||
| 58 | + | const faviconSrc = resolve(publicDir, "favicon.png"); | |||
| 59 | + | if (existsSync(faviconSrc)) { | |||
| 60 | + | copyFileSync(faviconSrc, resolve(outDir, "favicon.png")); | |||
| 61 | + | } | |||
| 62 | + | } | |||
| 63 | + | ||||
| 49 | // Build single page config | 64 | // Build single page config | ||
| 50 | function buildPageConfig(pageName: keyof typeof pages) { | 65 | function buildPageConfig(pageName: keyof typeof pages) { | ||
| 51 | const page = pages[pageName]; | 66 | const page = pages[pageName]; | ||
| @@ -55,6 +70,12 @@ function buildPageConfig(pageName: keyof typeof pages) { | |||||
| 55 | emitCss: false, // Inline component CSS for shadow DOM compatibility | 70 | emitCss: false, // Inline component CSS for shadow DOM compatibility | ||
| 56 | }), | 71 | }), | ||
| 57 | pageGenerator([page.html]), | 72 | pageGenerator([page.html]), | ||
| 73 | + | { | |||
| 74 | + | name: "copy-public-assets", | |||
| 75 | + | closeBundle() { | |||
| 76 | + | copyPublicAssets(); | |||
| 77 | + | }, | |||
| 78 | + | }, | |||
| 58 | ], | 79 | ], | ||
| 59 | build: { | 80 | build: { | ||
| 60 | rollupOptions: { | 81 | rollupOptions: { | ||