Improve dynamic webmanifest setup

pull/751/head
nimbleghost 2023-06-19 20:41:41 +02:00
parent d7aacb8b24
commit 000a3e005c
3 changed files with 10 additions and 13 deletions

View File

@ -41,6 +41,9 @@
<!-- Style overrides & fonts -->
<link rel="stylesheet" href="/static/css/app.css" type="text/css" />
<link rel="stylesheet" href="/static/css/fonts.css" type="text/css" />
<!-- PWA -->
<link rel="manifest" href="/manifest.webmanifest" />
</head>
<body>
<noscript>

View File

@ -245,7 +245,10 @@ if (!import.meta.env.DEV) {
// this is so we don't respond to `/` UNLESS it's the app root itself, defined above
/^\/.+$/,
],
denylist: [/^\/docs\/?$/],
// only /docs is required so it is navigable in the browser.
// the rest are nice-to-haves so the single-page-app doesn't try to handle them, but `fetch`
// and browser requests would work anyway.
denylist: [/^\/(docs|static|file).*$/, /^\/(app.html|manifest.webmanifest|sw.js|config.js)$/],
})
);

View File

@ -3,7 +3,7 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa";
export default defineConfig(() => ({
export default defineConfig(({ mode }) => ({
build: {
outDir: "build",
assetsDir: "static/media",
@ -43,24 +43,15 @@ export default defineConfig(() => ({
}),
],
},
manifest: {
name: "ntfy web",
short_name: "ntfy",
description:
"ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy.",
// The actual prod manifest is served from the go server, see server.go handleWebManifest.
manifest: mode === "development" && {
theme_color: "#317f6f",
start_url: "/",
icons: [
{
src: "/static/images/pwa-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/static/images/pwa-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
},
}),