vite.config.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import { sveltekit } from '@sveltejs/kit/vite';
  2. import { SvelteKitPWA } from '@vite-pwa/sveltekit';
  3. import { defineConfig } from 'vite';
  4. export default defineConfig({
  5. plugins: [
  6. sveltekit(),
  7. SvelteKitPWA({
  8. registerType: 'autoUpdate',
  9. injectRegister: null,
  10. strategies: 'generateSW',
  11. scope: '/',
  12. base: '/',
  13. manifest: {
  14. id: '/',
  15. name: 'Recipes',
  16. short_name: 'Recipes',
  17. description: 'Save, browse, and cook your recipes on any device.',
  18. lang: 'en',
  19. dir: 'ltr',
  20. start_url: '/',
  21. scope: '/',
  22. display: 'standalone',
  23. display_override: ['window-controls-overlay', 'standalone', 'minimal-ui', 'browser'],
  24. orientation: 'any',
  25. background_color: '#121212',
  26. theme_color: '#121212',
  27. categories: ['food', 'lifestyle', 'utilities'],
  28. prefer_related_applications: false,
  29. // Lets Chromium/Brave report an existing install via getInstalledRelatedApps().
  30. related_applications: [
  31. {
  32. platform: 'webapp',
  33. url: '/manifest.webmanifest'
  34. }
  35. ],
  36. icons: [
  37. {
  38. src: '/icon-72x72.png',
  39. sizes: '72x72',
  40. type: 'image/png',
  41. purpose: 'any'
  42. },
  43. {
  44. src: '/icon-96x96.png',
  45. sizes: '96x96',
  46. type: 'image/png',
  47. purpose: 'any'
  48. },
  49. {
  50. src: '/icon-128x128.png',
  51. sizes: '128x128',
  52. type: 'image/png',
  53. purpose: 'any'
  54. },
  55. {
  56. src: '/icon-144x144.png',
  57. sizes: '144x144',
  58. type: 'image/png',
  59. purpose: 'any'
  60. },
  61. {
  62. src: '/icon-152x152.png',
  63. sizes: '152x152',
  64. type: 'image/png',
  65. purpose: 'any'
  66. },
  67. {
  68. src: '/icon-192x192.png',
  69. sizes: '192x192',
  70. type: 'image/png',
  71. purpose: 'any'
  72. },
  73. {
  74. src: '/icon-384x384.png',
  75. sizes: '384x384',
  76. type: 'image/png',
  77. purpose: 'any'
  78. },
  79. {
  80. src: '/icon-512x512.png',
  81. sizes: '512x512',
  82. type: 'image/png',
  83. purpose: 'any'
  84. },
  85. {
  86. src: '/maskable-icon-192x192.png',
  87. sizes: '192x192',
  88. type: 'image/png',
  89. purpose: 'maskable'
  90. },
  91. {
  92. src: '/maskable-icon-512x512.png',
  93. sizes: '512x512',
  94. type: 'image/png',
  95. purpose: 'maskable'
  96. }
  97. ],
  98. shortcuts: [
  99. {
  100. name: 'Dashboard',
  101. short_name: 'Dashboard',
  102. description: 'View your recipes',
  103. url: '/dashboard',
  104. icons: [{ src: '/icon-192x192.png', sizes: '192x192', type: 'image/png' }]
  105. },
  106. {
  107. name: 'New recipe',
  108. short_name: 'New',
  109. description: 'Create a new recipe',
  110. url: '/recipe/new',
  111. icons: [{ src: '/icon-192x192.png', sizes: '192x192', type: 'image/png' }]
  112. }
  113. ]
  114. },
  115. workbox: {
  116. navigateFallback: null,
  117. globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,webmanifest,woff,woff2}'],
  118. cleanupOutdatedCaches: true,
  119. clientsClaim: true,
  120. skipWaiting: false,
  121. runtimeCaching: [
  122. {
  123. urlPattern: ({ request }) => request.mode === 'navigate',
  124. handler: 'NetworkFirst',
  125. options: {
  126. cacheName: 'pages',
  127. networkTimeoutSeconds: 3,
  128. expiration: {
  129. maxEntries: 64,
  130. maxAgeSeconds: 60 * 60 * 24
  131. },
  132. cacheableResponse: {
  133. statuses: [0, 200]
  134. }
  135. }
  136. },
  137. {
  138. urlPattern: ({ request }) =>
  139. request.destination === 'image' ||
  140. request.destination === 'font' ||
  141. request.destination === 'style' ||
  142. request.destination === 'script',
  143. handler: 'StaleWhileRevalidate',
  144. options: {
  145. cacheName: 'assets',
  146. expiration: {
  147. maxEntries: 128,
  148. maxAgeSeconds: 60 * 60 * 24 * 30
  149. },
  150. cacheableResponse: {
  151. statuses: [0, 200]
  152. }
  153. }
  154. }
  155. ]
  156. },
  157. devOptions: {
  158. enabled: false,
  159. suppressWarnings: true,
  160. type: 'module'
  161. },
  162. kit: {
  163. includeVersionFile: true
  164. }
  165. })
  166. ]
  167. });