vite.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. export default defineConfig(() => ({
  6. build: {
  7. outDir: "build",
  8. assetsDir: "static/media",
  9. sourcemap: true,
  10. },
  11. server: {
  12. port: 3000,
  13. },
  14. plugins: [
  15. react(),
  16. VitePWA({
  17. registerType: "autoUpdate",
  18. injectRegister: "inline",
  19. strategies: "injectManifest",
  20. devOptions: {
  21. enabled: true,
  22. /* when using generateSW the PWA plugin will switch to classic */
  23. type: "module",
  24. navigateFallback: "index.html",
  25. },
  26. injectManifest: {
  27. globPatterns: ["**/*.{js,css,html,mp3,ico,png,svg,json}"],
  28. globIgnores: ["config.js"],
  29. manifestTransforms: [
  30. (entries) => ({
  31. manifest: entries.map((entry) =>
  32. // this matches the build step in the Makefile.
  33. // since ntfy needs the ability to serve another page on /index.html,
  34. // it's renamed and served from server.go as app.html as well.
  35. entry.url === "index.html"
  36. ? {
  37. ...entry,
  38. url: "app.html",
  39. }
  40. : entry
  41. ),
  42. }),
  43. ],
  44. },
  45. manifest: {
  46. name: "ntfy web",
  47. short_name: "ntfy",
  48. description:
  49. "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.",
  50. theme_color: "#317f6f",
  51. start_url: "/",
  52. icons: [
  53. {
  54. src: "/static/images/pwa-192x192.png",
  55. sizes: "192x192",
  56. type: "image/png",
  57. },
  58. {
  59. src: "/static/images/pwa-512x512.png",
  60. sizes: "512x512",
  61. type: "image/png",
  62. },
  63. ],
  64. },
  65. }),
  66. ],
  67. }));