2023-05-24 13:24:34 +03:00
|
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
import react from "@vitejs/plugin-react";
|
2023-05-24 22:36:01 +03:00
|
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
|
|
|
2023-06-19 21:41:41 +03:00
|
|
|
export default defineConfig(({ mode }) => ({
|
2023-05-24 13:24:34 +03:00
|
|
|
build: {
|
|
|
|
outDir: "build",
|
2023-05-25 04:44:12 +03:00
|
|
|
assetsDir: "static/media",
|
2023-05-24 22:36:01 +03:00
|
|
|
sourcemap: true,
|
2023-05-24 13:24:34 +03:00
|
|
|
},
|
|
|
|
server: {
|
|
|
|
port: 3000,
|
|
|
|
},
|
2023-05-24 22:36:01 +03:00
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
VitePWA({
|
|
|
|
registerType: "autoUpdate",
|
2023-06-30 09:59:20 +03:00
|
|
|
// see registerSW.js imported by index.jsx
|
2023-06-29 16:07:18 +03:00
|
|
|
injectRegister: null,
|
2023-05-24 22:36:01 +03:00
|
|
|
strategies: "injectManifest",
|
|
|
|
devOptions: {
|
2023-06-15 00:41:57 +03:00
|
|
|
enabled: true,
|
2023-05-24 22:36:01 +03:00
|
|
|
/* when using generateSW the PWA plugin will switch to classic */
|
|
|
|
type: "module",
|
|
|
|
navigateFallback: "index.html",
|
|
|
|
},
|
|
|
|
injectManifest: {
|
2023-06-29 13:20:42 +03:00
|
|
|
globPatterns: ["**/*.{js,css,html,ico,png,svg,json}"],
|
2023-05-24 22:36:01 +03:00
|
|
|
globIgnores: ["config.js"],
|
|
|
|
manifestTransforms: [
|
|
|
|
(entries) => ({
|
|
|
|
manifest: entries.map((entry) =>
|
2023-06-19 11:50:14 +03: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.
|
2023-05-24 22:36:01 +03:00
|
|
|
entry.url === "index.html"
|
|
|
|
? {
|
|
|
|
...entry,
|
2023-06-19 11:50:14 +03:00
|
|
|
url: "app.html",
|
2023-05-24 22:36:01 +03:00
|
|
|
}
|
|
|
|
: entry
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2023-06-19 21:41:41 +03:00
|
|
|
// The actual prod manifest is served from the go server, see server.go handleWebManifest.
|
|
|
|
manifest: mode === "development" && {
|
2023-05-24 22:36:01 +03:00
|
|
|
theme_color: "#317f6f",
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: "/static/images/pwa-192x192.png",
|
|
|
|
sizes: "192x192",
|
|
|
|
type: "image/png",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2023-05-24 13:24:34 +03:00
|
|
|
}));
|