-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
vite.web.config.ts
62 lines (59 loc) · 2.1 KB
/
vite.web.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
import { defineConfig, loadEnv } from 'vite'
import { VitePWA } from 'vite-plugin-pwa';
import colorPalette from './color_palette';
import baseConfig from './vite.config';
import { resolve, join } from 'path';
const plugins = baseConfig instanceof Promise || typeof baseConfig !== 'object' ? [] : baseConfig.plugins;
export default ({ mode }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};
return defineConfig({
...baseConfig,
server: {
port: 3000
},
resolve: {
alias: {
'/src/main.ts': resolve(__dirname, join('.', 'src', 'web', 'main.ts'))
}
},
plugins: [
...plugins,
VitePWA({
registerType: 'autoUpdate',
includeManifestIcons: true,
workbox: {
runtimeCaching: mode === 'production' && process.env.VITE_AVATAR_BASE_URL ? [
{
urlPattern: new RegExp(`${process.env.VITE_AVATAR_BASE_URL.replace('/', '\\/')}\\/images\\/100x102\\/.*\.jpg`),
handler: "CacheFirst",
options: {
cacheName: 'avatar',
expiration: {
maxEntries: 500,
maxAgeSeconds: 60 * 60 * 24 * 30
},
cacheableResponse: {
statuses: [200]
}
}
}
] : []
},
manifest: {
background_color: "#FFFFFF",
theme_color: colorPalette.primary[500],
name: "MyUIC Neo",
short_name: 'MyUIC Neo',
display: "standalone",
icons: [
{ "src": "/icons/favicon.ico", "type": "image/x-icon", "sizes": "16x16 32x32" },
{ "src": "/icons/icon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/icons/icon-512.png", "type": "image/png", "sizes": "512x512" },
{ "src": "/icons/icon-192-maskable.png", "type": "image/png", "sizes": "192x192", "purpose": "maskable" },
{ "src": "/icons/icon-512-maskable.png", "type": "image/png", "sizes": "512x512", "purpose": "maskable" }
],
},
}),
]
});
}