48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
tsconfigPaths(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate', // Automatically updates the service worker when a new version is available
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,png,jpg,svg}'], // Cache all common asset types
|
|
maximumFileSizeToCacheInBytes: 20 * 1024 * 1024, // 20 MiB
|
|
cleanupOutdatedCaches: true,
|
|
navigateFallback: "/indexV2.html",
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: ({ request }) => request.destination === 'document',
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'html-cache',
|
|
},
|
|
},
|
|
{
|
|
urlPattern: ({ request }) =>
|
|
['style', 'script', 'worker'].includes(request.destination),
|
|
handler: 'StaleWhileRevalidate',
|
|
options: {
|
|
cacheName: 'assets-cache',
|
|
},
|
|
},
|
|
]
|
|
},
|
|
}),
|
|
],
|
|
build: {
|
|
outDir: './build',
|
|
sourcemap: true,
|
|
minify: false,
|
|
target: 'esnext'
|
|
},
|
|
esbuild: {
|
|
keepNames: true, // Prevent function name mangling
|
|
},
|
|
|
|
})
|