49 lines
1 KiB
TypeScript
49 lines
1 KiB
TypeScript
|
import { defineConfig } from 'vite';
|
||
|
import { VitePWA } from 'vite-plugin-pwa';
|
||
|
|
||
|
/** @type {import('vite').UserConfig} */
|
||
|
export default defineConfig({
|
||
|
base: "/",
|
||
|
build: {
|
||
|
sourcemap: true,
|
||
|
assetsDir: "code",
|
||
|
},
|
||
|
plugins: [
|
||
|
VitePWA({
|
||
|
registerType: "autoUpdate",
|
||
|
injectRegister: false,
|
||
|
manifest: false,
|
||
|
workbox: {
|
||
|
globDirectory: 'dist',
|
||
|
globPatterns: [
|
||
|
'**/*.{html,js,css,png,webp,jpg}'
|
||
|
],
|
||
|
runtimeCaching: [
|
||
|
{
|
||
|
urlPattern: /^https:\/\/unpkg\.com\/.*/i,
|
||
|
handler: 'CacheFirst',
|
||
|
options: {
|
||
|
cacheName: 'unpkg-libs-cache',
|
||
|
expiration: {
|
||
|
maxEntries: 10,
|
||
|
maxAgeSeconds: 60 * 60 * 24 * 365 // <== 365 days
|
||
|
},
|
||
|
cacheableResponse: {
|
||
|
statuses: [0, 200]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
devOptions: {
|
||
|
enabled: true
|
||
|
}
|
||
|
})
|
||
|
],
|
||
|
server: {
|
||
|
watch: {
|
||
|
usePolling: true
|
||
|
}
|
||
|
}
|
||
|
})
|