2022-12-18 00:15:19 +00:00
|
|
|
import { isCI, isDevelopment } from 'std-env'
|
2022-12-17 23:29:16 +00:00
|
|
|
import type { VitePWANuxtOptions } from '../modules/pwa/types'
|
|
|
|
|
|
|
|
const isPreview = process.env.PULL_REQUEST === 'true'
|
|
|
|
|
2022-12-28 14:08:03 +00:00
|
|
|
export const pwa: VitePWANuxtOptions = {
|
2022-12-17 23:29:16 +00:00
|
|
|
mode: isCI ? 'production' : 'development',
|
2022-12-21 00:06:51 +00:00
|
|
|
// disable PWA only when in preview mode
|
2022-12-22 13:48:20 +00:00
|
|
|
disable: /* temporarily test in CI isPreview || */ (isDevelopment && process.env.VITE_DEV_PWA !== 'true'),
|
2022-12-17 23:29:16 +00:00
|
|
|
scope: '/',
|
|
|
|
srcDir: './service-worker',
|
|
|
|
filename: 'sw.ts',
|
|
|
|
strategies: 'injectManifest',
|
|
|
|
injectRegister: false,
|
|
|
|
includeManifestIcons: false,
|
|
|
|
manifest: {
|
|
|
|
scope: '/',
|
|
|
|
id: '/',
|
|
|
|
name: `Elk${isCI ? isPreview ? ' (preview)' : '' : ' (dev)'}`,
|
|
|
|
short_name: `Elk${isCI ? isPreview ? ' (preview)' : '' : ' (dev)'}`,
|
|
|
|
description: `A nimble Mastodon Web Client${isCI ? isPreview ? ' (preview)' : '' : ' (development)'}`,
|
|
|
|
theme_color: '#ffffff',
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: 'pwa-192x192.png',
|
|
|
|
sizes: '192x192',
|
|
|
|
type: 'image/png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'pwa-512x512.png',
|
|
|
|
sizes: '512x512',
|
|
|
|
type: 'image/png',
|
|
|
|
},
|
2022-12-19 22:37:23 +00:00
|
|
|
/*
|
2022-12-17 23:29:16 +00:00
|
|
|
{
|
|
|
|
src: 'logo.svg',
|
|
|
|
sizes: '250x250',
|
|
|
|
type: 'image/png',
|
|
|
|
purpose: 'any maskable',
|
|
|
|
},
|
2022-12-19 22:37:23 +00:00
|
|
|
*/
|
2022-12-17 23:29:16 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
injectManifest: {
|
|
|
|
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm}'],
|
2023-01-03 09:57:41 +00:00
|
|
|
globIgnores: ['emojis/**'],
|
2022-12-17 23:29:16 +00:00
|
|
|
},
|
|
|
|
devOptions: {
|
|
|
|
enabled: process.env.VITE_DEV_PWA === 'true',
|
|
|
|
type: 'module',
|
|
|
|
},
|
|
|
|
}
|