-
Notifications
You must be signed in to change notification settings - Fork 17
/
vite.config.ts
156 lines (151 loc) · 4 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* eslint-disable camelcase */
import react from '@vitejs/plugin-react-swc'
import { defineConfig, loadEnv, PluginOption } from 'vite'
import mkcert from 'vite-plugin-mkcert'
import loadVersion from 'vite-plugin-package-version'
import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa'
import topLevelAwait from 'vite-plugin-top-level-await'
import wasm from 'vite-plugin-wasm'
import tsconfigPaths from 'vite-tsconfig-paths'
const pwaOptions: Partial<VitePWAOptions> = {
base: '/',
injectRegister: 'inline',
includeAssets: ['logo-brand.svg', 'sitemap.xml'],
manifest: {
start_url: '.',
display: 'standalone',
background_color: '#111110',
name: 'Geyser',
short_name: 'Geyser',
description:
'Geyser is a bitcoin crowdfunding platform that enables campaign creators to launch their projects with rewards and engage their communities with posts and content.',
theme_color: '#111110',
icons: [
{
src: 'logo-brand.svg',
sizes: 'any',
type: 'image/svg+xml',
},
{
src: '/icons/60.png',
sizes: '60x60',
type: 'image/png',
},
{
src: '/icons/120.png',
sizes: '120x120',
type: 'image/png',
},
{
src: '/icons/180-padded.png',
sizes: '180x180',
type: 'image/png',
},
{
src: '/icons/192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/icons/512-padded.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: '/icons/192-maskable.png',
sizes: '192x192',
type: 'image/png',
purpose: 'maskable',
},
{
src: '/icons/512-maskable.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
maximumFileSizeToCacheInBytes: 5242880,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
}
export default defineConfig(({ command, mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')
const server = {
port: Number(env.PORT),
https: Boolean(env.HTTPS),
proxy: undefined,
// open: env.DOCKER ? false : `http://dev.geyser.fund:${PORT}/`,
watch: {
usePolling: true,
},
host: true, // needed for the Docker Container port mapping to work
strictPort: true,
}
if (mode === 'development') {
console.log(`
==================================================================================================
"Geyser - App" will available at http://dev.geyser.fund:${env.PORT}/
==================================================================================================
`)
}
pwaOptions.mode = env.APP_ENV === 'development' ? 'development' : 'production'
const plugins: PluginOption[] = [
VitePWA(pwaOptions),
react(),
tsconfigPaths(),
loadVersion(),
wasm(),
topLevelAwait(),
]
if (mode !== 'production') {
plugins.push(mkcert())
}
return {
plugins,
resolve: {
alias: {
'@': '/src',
},
},
server,
define: {
'process.env': env,
__APP_ENV__: env.APP_ENV,
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './setupTests.ts',
},
optimizeDeps: {
include: ['ecpair', 'tiny-secp256k1'],
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
}
})