-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
88 lines (85 loc) · 2.59 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { VitePWA } from 'vite-plugin-pwa';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import { visualizer } from 'rollup-plugin-visualizer';
import * as child from 'child_process';
const commitId = child.execSync('git rev-parse --short HEAD').toString();
const branch = child.execSync('git rev-parse --abbrev-ref HEAD').toString();
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
base: '/regend-webui/',
plugins: [
react(),
wasm(),
VitePWA({
includeAssets: ['favicon.ico', 'apple-touch-icon.png'],
registerType: 'prompt',
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
maximumFileSizeToCacheInBytes: 12 * 1024 * 1024,
},
strategies: 'generateSW',
manifest: {
background_color: '#94c0fa',
categories: ['graphics'],
display: 'fullscreen',
icons: [
{
src: '/regend-webui/192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/regend-webui/256.png',
sizes: '256x256',
type: 'image/png',
},
{
src: '/regend-webui/384.png',
sizes: '384x384',
type: 'image/png',
},
{
src: '/regend-webui/512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: '/regend-webui/512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
],
name: 'Regend WebUI',
orientation: 'any',
scope: '/',
short_name: 'Regend',
start_url: '/regend-webui/',
theme_color: '#3884eb',
},
}),
topLevelAwait({
// The export name of top-level await promise for each chunk module
promiseExportName: '__tla',
// The function to generate import names of top-level await promise in each chunk module
promiseImportName: (i) => `__tla_${i}`,
}),
mode === 'analyze' &&
visualizer({
open: true,
filename: 'dist/stats.html',
gzipSize: true,
brotliSize: true,
template: 'treemap',
}),
],
define: {
__COMMIT_ID__: JSON.stringify(commitId.trim()),
__GIT_BRANCH__: JSON.stringify(branch.trim()),
},
};
});