1
0

vite.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // please look at develop.md for how to run your browser
  6. // in a mode allowing insecure service worker testing
  7. // this turns on:
  8. // - the service worker in dev mode
  9. // - turns off automatically opening the browser
  10. const enableLocalPWATesting = process.env.ENABLE_DEV_PWA;
  11. export default defineConfig(() => ({
  12. build: {
  13. outDir: "build",
  14. assetsDir: "static/media",
  15. sourcemap: true,
  16. },
  17. server: {
  18. port: 3000,
  19. open: !enableLocalPWATesting,
  20. },
  21. plugins: [
  22. react(),
  23. VitePWA({
  24. registerType: "autoUpdate",
  25. injectRegister: "inline",
  26. strategies: "injectManifest",
  27. devOptions: {
  28. enabled: enableLocalPWATesting,
  29. /* when using generateSW the PWA plugin will switch to classic */
  30. type: "module",
  31. navigateFallback: "index.html",
  32. },
  33. injectManifest: {
  34. globPatterns: ["**/*.{js,css,html,mp3,png,svg,json}"],
  35. globIgnores: ["config.js"],
  36. manifestTransforms: [
  37. (entries) => ({
  38. manifest: entries.map((entry) =>
  39. entry.url === "index.html"
  40. ? {
  41. ...entry,
  42. url: "/",
  43. }
  44. : entry
  45. ),
  46. }),
  47. ],
  48. },
  49. manifest: {
  50. name: "ntfy web",
  51. short_name: "ntfy",
  52. description:
  53. "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.",
  54. theme_color: "#317f6f",
  55. start_url: "/",
  56. icons: [
  57. {
  58. src: "/static/images/pwa-192x192.png",
  59. sizes: "192x192",
  60. type: "image/png",
  61. },
  62. {
  63. src: "/static/images/pwa-512x512.png",
  64. sizes: "512x512",
  65. type: "image/png",
  66. },
  67. ],
  68. },
  69. }),
  70. ],
  71. }));