| 1 |
/* eslint-disable import/no-extraneous-dependencies */ |
| 2 |
import { defineConfig } from "vite"; |
| 3 |
import react from "@vitejs/plugin-react"; |
| 4 |
import { VitePWA } from "vite-plugin-pwa"; |
| 5 |
|
| 6 |
export default defineConfig(({ mode }) => ({ |
| 7 |
build: { |
| 8 |
outDir: "build", |
| 9 |
assetsDir: "static/media", |
| 10 |
sourcemap: true, |
| 11 |
}, |
| 12 |
server: { |
| 13 |
port: 3000, |
| 14 |
}, |
| 15 |
plugins: [ |
| 16 |
react(), |
| 17 |
VitePWA({ |
| 18 |
registerType: "autoUpdate", |
| 19 |
// see registerSW.js imported by index.jsx |
| 20 |
injectRegister: null, |
| 21 |
strategies: "injectManifest", |
| 22 |
devOptions: { |
| 23 |
enabled: true, |
| 24 |
/* when using generateSW the PWA plugin will switch to classic */ |
| 25 |
type: "module", |
| 26 |
navigateFallback: "index.html", |
| 27 |
}, |
| 28 |
injectManifest: { |
| 29 |
globPatterns: ["**/*.{js,css,html,ico,png,svg,json}"], |
| 30 |
globIgnores: ["config.js"], |
| 31 |
manifestTransforms: [ |
| 32 |
(entries) => ({ |
| 33 |
manifest: entries.map((entry) => |
| 34 |
// this matches the build step in the Makefile. |
| 35 |
// since ntfy needs the ability to serve another page on /index.html, |
| 36 |
// it's renamed and served from server.go as app.html as well. |
| 37 |
entry.url === "index.html" |
| 38 |
? { |
| 39 |
...entry, |
| 40 |
url: "app.html", |
| 41 |
} |
| 42 |
: entry, |
| 43 |
), |
| 44 |
}), |
| 45 |
], |
| 46 |
}, |
| 47 |
// The actual prod manifest is served from the go server, see server.go handleWebManifest. |
| 48 |
manifest: mode === "development" && { |
| 49 |
theme_color: "#317f6f", |
| 50 |
icons: [ |
| 51 |
{ |
| 52 |
src: "/static/images/pwa-192x192.png", |
| 53 |
sizes: "192x192", |
| 54 |
type: "image/png", |
| 55 |
}, |
| 56 |
], |
| 57 |
}, |
| 58 |
}), |
| 59 |
], |
| 60 |
})); |