generated from cerivitos/svelte-pwa-now
-
Notifications
You must be signed in to change notification settings - Fork 98
/
vite.config.js
51 lines (44 loc) · 1.27 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {defineConfig} from "vite";
import {svelte} from "@sveltejs/vite-plugin-svelte";
import { VitePWA } from 'vite-plugin-pwa'
import replace from '@rollup/plugin-replace'
const pwaOptions = {
mode: 'development',
base: '/',
includeAssets: ['favicon.svg'],
manifest: {
name: 'NENO',
short_name: 'NENO',
theme_color: '#f3f4f6',
icons: [
{
src: 'neno.png', // <== don't add slash, for testing
sizes: '512x512',
type: 'image/png',
},
],
},
}
const replaceOptions = { __DATE__: new Date().toISOString() }
const claims = process.env.CLAIMS === 'true'
const reload = process.env.RELOAD_SW === 'true'
if (process.env.SW === 'true') {
pwaOptions.srcDir = 'src'
pwaOptions.filename = claims ? 'claims-sw.ts' : 'prompt-sw.ts'
pwaOptions.strategies = 'injectManifest'
pwaOptions.manifest.name = 'PWA Inject Manifest'
pwaOptions.manifest.short_name = 'PWA Inject'
}
if (claims)
pwaOptions.registerType = 'autoUpdate'
if (reload) {
// @ts-ignore
replaceOptions.__RELOAD_SW__ = 'true'
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte(),
VitePWA(pwaOptions),
replace(replaceOptions),
]
});