-
Notifications
You must be signed in to change notification settings - Fork 26
/
vite.config.ts
80 lines (78 loc) · 1.68 KB
/
vite.config.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import react from '@vitejs/plugin-react'
import autoprefixer from 'autoprefixer'
import path from 'path'
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { VitePWA } from 'vite-plugin-pwa'
import type { VitePWAOptions } from 'vite-plugin-pwa'
const pwaOptions: Partial<VitePWAOptions> = {
mode: 'production',
base: '/',
strategies: 'injectManifest',
srcDir: 'src',
filename: 'main-sw.ts',
injectManifest: {
injectionPoint: undefined
},
injectRegister: 'inline',
registerType: 'autoUpdate',
includeAssets: ['favicon.svg'],
manifest: {
name: 'Web3Inbox',
short_name: 'Web3Inbox',
icons: [
{
src: 'pwa-196x196.png',
sizes: '196x196',
type: 'image/png'
},
{
src: 'pwa-270x270.png',
sizes: '270x270',
type: 'image/png'
},
{
src: 'pwa-270x270.png',
sizes: '270x270',
type: 'image/png',
purpose: 'any maskable'
}
]
},
devOptions: {
enabled: process.env.SW_DEV === 'true',
/* when using generateSW the PWA plugin will switch to classic */
type: 'module',
navigateFallback: 'index.html'
}
}
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
build: {
target: 'es2020'
},
optimizeDeps: {
esbuildOptions: {
target: 'es2020'
}
},
plugins: [
react(),
nodePolyfills({
protocolImports: true
}),
VitePWA(pwaOptions)
],
css: {
postcss: {
plugins: [autoprefixer({})]
}
}
}
})