Improve dynamic webmanifest setup

This commit is contained in:
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 --> <!-- Style overrides & fonts -->
<link rel="stylesheet" href="/static/css/app.css" type="text/css" /> <link rel="stylesheet" href="/static/css/app.css" type="text/css" />
<link rel="stylesheet" href="/static/css/fonts.css" type="text/css" /> <link rel="stylesheet" href="/static/css/fonts.css" type="text/css" />
<!-- PWA -->
<link rel="manifest" href="/manifest.webmanifest" />
</head> </head>
<body> <body>
<noscript> <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 // 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 react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa"; import { VitePWA } from "vite-plugin-pwa";
export default defineConfig(() => ({ export default defineConfig(({ mode }) => ({
build: { build: {
outDir: "build", outDir: "build",
assetsDir: "static/media", assetsDir: "static/media",
@ -43,24 +43,15 @@ export default defineConfig(() => ({
}), }),
], ],
}, },
manifest: { // The actual prod manifest is served from the go server, see server.go handleWebManifest.
name: "ntfy web", manifest: mode === "development" && {
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.",
theme_color: "#317f6f", theme_color: "#317f6f",
start_url: "/",
icons: [ icons: [
{ {
src: "/static/images/pwa-192x192.png", src: "/static/images/pwa-192x192.png",
sizes: "192x192", sizes: "192x192",
type: "image/png", type: "image/png",
}, },
{
src: "/static/images/pwa-512x512.png",
sizes: "512x512",
type: "image/png",
},
], ],
}, },
}), }),