-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
110 lines (108 loc) · 2.94 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
/// <reference types="vitest" />
import { defineConfig } from 'vite'
// import preact from '@preact/preset-vite'
import tsconfigPaths from "vite-tsconfig-paths"
import { ssr } from 'vite-plugin-ssr/plugin'
import { VitePWA } from 'vite-plugin-pwa'
import { visualizer } from "rollup-plugin-visualizer";
// import legacy from '@vitejs/plugin-legacy'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode, ssrBuild }) => ({
server: {
headers: {
'service-worker-allowed': '/'
}
},
...((command == 'serve') && {
define: {
global: {},
}
}),
preview: {
headers: {
'service-worker-allowed': '/'
}
},
test: {
globals: true,
environment: 'happy-dom',
},
plugins: [
// preact(),
tsconfigPaths(),
ssr({ prerender: true }),
// legacy({
// modernPolyfills: true,
// targets: [
// "> 0.5%",
// "last 1 version",
// "Edge >= 16",
// "Opera >= 58",
// "Safari >= 10.1",
// "Firefox >= 52",
// "Chrome >= 57",
// "iOS >= 11",
// "Samsung >= 8",
// "ChromeAndroid >= 71",
// "Android >= 4.3",
// "not dead",
// ],
// }),
VitePWA({
srcDir: 'src/modules/pwa',
registerType: 'autoUpdate',
strategies: 'injectManifest',
filename: 'service-worker.ts',
injectRegister: null,
// devOptions: {
// enabled: true,
// },
manifest: {
"name": "Sr Smith",
"short_name": "Sr-smith",
"icons": [
{
"src": "/pwa/manifest-icon-192.maskable.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/pwa/manifest-icon-512.maskable.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}],
"theme_color": "#000000",
"background_color": "#000000",
"start_url": "/",
"display": "standalone",
"orientation": "portrait"
}
}),
visualizer({
// emitFile: true,
// filename: "stats.html",
gzipSize: true,
template: 'network',
}),
],
// We manually add a list of dependencies to be pre-bundled, in order to avoid a page reload at dev start which breaks vite-plugin-ssr's CI
// optimizeDeps: {
// include: ['preact', 'preact/devtools', 'preact/debug', 'preact/jsx-dev-runtime', 'preact/hooks']
// },
resolve: {
alias: {
// 'react': 'preact/compat',
// 'react-dom': 'preact/compat',
'lodash': 'lodash-es',
'robot3': 'robot3/packages/core'
}
},
ssr: {
// Add libraries containing invalid ESM here
noExternal: command == 'serve' ?
['jotai', 'jsxgraph', 'react-hotkeys-hook', 'react-robot', 'robot3', 'typesafe-i18n']
: ['jotai', 'jsxgraph', 'react-hotkeys-hook', 'robot3', 'workbox-window', '@heroicons/react']
}
}))