-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
142 lines (141 loc) · 4.96 KB
/
vite.config.ts
File metadata and controls
142 lines (141 loc) · 4.96 KB
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';
import fs from 'fs';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
resolve: {
alias: {
'@': '/src',
},
},
define: {
__BUILD_TIMESTAMP__: new Date().getTime(),
__README_CONTENT__: JSON.stringify(fs.readFileSync(path.resolve(__dirname, 'README.md'), 'utf-8')),
},
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: [
'favicon.ico',
'images/apple-touch-icon.png',
'images/favicon-16x16.png',
'images/favicon-32x32.png',
'images/shortcuts-icon.png',
'images/circuit.png',
],
manifest: {
name: '鱼 sifu 工具包',
short_name: '工具包',
description: '鱼 sifu 的在线小工具合集包',
theme_color: 'rgb(248, 249, 250)',
background_color: 'white',
lang: 'zh-CN',
start_url: '/',
dir: 'ltr',
display: 'standalone',
icons: [
{
src: 'images/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'images/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png'
}
],
shortcuts: [
{
name: 'JSON',
url: '/json',
icons: [
{
src: 'images/shortcuts-icon.png',
sizes: '96x96',
type: 'image/png'
}
],
},
{
name: '编解码',
url: '/encoder',
icons: [
{
src: 'images/shortcuts-icon.png',
sizes: '96x96',
type: 'image/png'
}
],
},
{
name: '文本处理',
url: '/textproc',
icons: [
{
src: 'images/shortcuts-icon.png',
sizes: '96x96',
type: 'image/png'
}
],
},
{
name: '大卡计算',
url: '/kcal',
icons: [
{
src: 'images/shortcuts-icon.png',
sizes: '96x96',
type: 'image/png'
}
],
},
{
name: '密码机',
url: '/code',
icons: [
{
src: 'images/shortcuts-icon.png',
sizes: '96x96',
type: 'image/png'
}
],
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
globIgnores: ['**/assets/vendor-transformers-*.js', '**/assets/vendor-onnxruntime-*.js'],
navigateFallbackDenylist: [/^\/assets\//, /\/[^/?]+\.(js|css|wasm)$/],
},
}),
],
build: {
rollupOptions: {
output: {
manualChunks(id: string) {
if (id.includes('node_modules')) {
if (id.includes('sql-formatter')) {
return 'vendor-sqlfmt';
} else if (id.includes('react')) {
return 'vendor-react';
} else if (id.includes('onnxruntime')) {
return 'vendor-onnxruntime';
} else if (id.includes('transformers')) {
return 'vendor-transformers';
} else {
return 'vendor-others';
}
}
}
}
}
},
optimizeDeps: {
exclude: ['@huggingface/transformers'] // Prevent optimization of transformers.js
}
})