2022-12-18 09:15:19 +09:00
|
|
|
import { isCI, isDevelopment } from 'std-env'
|
2022-12-18 08:29:16 +09:00
|
|
|
import type { VitePWANuxtOptions } from '../modules/pwa/types'
|
|
|
|
|
2022-12-28 23:08:03 +09:00
|
|
|
export const pwa: VitePWANuxtOptions = {
|
2022-12-18 08:29:16 +09:00
|
|
|
mode: isCI ? 'production' : 'development',
|
2022-12-21 09:06:51 +09:00
|
|
|
// disable PWA only when in preview mode
|
2022-12-22 22:48:20 +09:00
|
|
|
disable: /* temporarily test in CI isPreview || */ (isDevelopment && process.env.VITE_DEV_PWA !== 'true'),
|
2022-12-18 08:29:16 +09:00
|
|
|
scope: '/',
|
|
|
|
srcDir: './service-worker',
|
|
|
|
filename: 'sw.ts',
|
|
|
|
strategies: 'injectManifest',
|
|
|
|
injectRegister: false,
|
|
|
|
includeManifestIcons: false,
|
2023-01-06 21:48:43 +09:00
|
|
|
manifest: false,
|
2022-12-18 08:29:16 +09:00
|
|
|
injectManifest: {
|
2023-01-06 21:48:43 +09:00
|
|
|
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm,webmanifest}'],
|
2023-01-10 04:34:26 +09:00
|
|
|
globIgnores: ['emojis/**', 'shiki/**'],
|
2022-12-18 08:29:16 +09:00
|
|
|
},
|
|
|
|
devOptions: {
|
|
|
|
enabled: process.env.VITE_DEV_PWA === 'true',
|
|
|
|
type: 'module',
|
|
|
|
},
|
|
|
|
}
|