1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-01 01:21:15 +01:00
ntfy/web/vite.config.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa";
2023-06-19 20:41:41 +02:00
export default defineConfig(({ mode }) => ({
build: {
outDir: "build",
2023-05-25 03:44:12 +02:00
assetsDir: "static/media",
sourcemap: true,
},
server: {
port: 3000,
},
plugins: [
react(),
VitePWA({
registerType: "autoUpdate",
2023-06-30 08:59:20 +02:00
// see registerSW.js imported by index.jsx
2023-06-29 15:07:18 +02:00
injectRegister: null,
strategies: "injectManifest",
devOptions: {
enabled: true,
/* when using generateSW the PWA plugin will switch to classic */
type: "module",
navigateFallback: "index.html",
},
injectManifest: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,json}"],
globIgnores: ["config.js"],
manifestTransforms: [
(entries) => ({
manifest: entries.map((entry) =>
2023-06-19 10:50:14 +02:00
// this matches the build step in the Makefile.
// since ntfy needs the ability to serve another page on /index.html,
// it's renamed and served from server.go as app.html as well.
entry.url === "index.html"
? {
...entry,
2023-06-19 10:50:14 +02:00
url: "app.html",
}
: entry
),
}),
],
},
2023-06-19 20:41:41 +02:00
// The actual prod manifest is served from the go server, see server.go handleWebManifest.
manifest: mode === "development" && {
theme_color: "#317f6f",
icons: [
{
src: "/static/images/pwa-192x192.png",
sizes: "192x192",
type: "image/png",
},
],
},
}),
],
}));