-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
105 lines (99 loc) · 3.29 KB
/
vite.config.js
File metadata and controls
105 lines (99 loc) · 3.29 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
import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';
import { viteStaticCopy } from 'vite-plugin-static-copy';
// https://vitejs.dev/config/
export default defineConfig({
// Include WASM-related files as assets so they're copied to the build output
assetsInclude: ['**/*.wasm'],
build: {
rollupOptions: {
output: {
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: ({name}) => {
if (/\.(gif|jpe?g|png|svg)$/.test(name ?? '')){
return 'assets/images/[name]-[hash][extname]';
}
if (/\.css$/.test(name ?? '')) {
return 'assets/css/[name]-[hash][extname]';
}
// Keep WASM files in assets/wasm without hash for predictable paths
if (/\.wasm$/.test(name ?? '')) {
return 'assets/wasm/[name][extname]';
}
return 'assets/[name]-[hash][extname]';
},
},
},
},
// Worker configuration - use ES modules format instead of IIFE
worker: {
format: 'es',
rollupOptions: {
output: {
entryFileNames: 'assets/workers/[name]-[hash].js',
chunkFileNames: 'assets/workers/[name]-[hash].js',
},
},
resolve: {
alias: [
{
find: '@',
replacement: fileURLToPath(new URL('./src', import.meta.url))
},
],
},
},
css: {
preprocessorOptions: {
scss: {
quietDeps: true,
},
},
},
publicDir: 'src/public',
plugins: [
vue(),
viteCompression({filter: /\.(js|mjs|json|css|html|wasm)$/i}),
// Copy WASM files from assets to wasm/ folder served at /wasm/
viteStaticCopy({
targets: [
{ src: 'src/assets/js/libMKF.wasm.js', dest: 'wasm' },
{ src: 'src/assets/js/libMKF.wasm.wasm', dest: 'wasm' },
{ src: 'src/assets/js/mvbpp.js', dest: 'wasm' },
{ src: 'src/assets/js/mvbpp.wasm', dest: 'wasm' },
]
}),
],
resolve: {
alias: [
{
find: '@',
replacement: fileURLToPath(new URL('./src', import.meta.url))
},
{
find: 'WebSharedComponents',
replacement: fileURLToPath(new URL('./WebSharedComponents', import.meta.url))
},
],
},
server: {
fs: { allow: ['..'] },
watch: { usePolling: true, interval: 1000 },
hmr: {
protocol: 'ws',
host: 'localhost',
port: 5173
},
proxy: {
'/api': {
target: 'https://localhost:8888',
changeOrigin: true,
secure: false,
ws: true,
}
}
}
})