forked from MITIH-Dreamlab/JingSpringThing
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
93 lines (85 loc) · 2.46 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const isProd = mode === 'production';
const isQuest = process.env.npm_config_platform === 'quest';
return {
root: 'client',
base: './',
build: {
outDir: resolve(__dirname, 'data/public/dist'),
emptyOutDir: true,
sourcemap: !isProd,
minify: isProd ? 'esbuild' : false, // Enable minification in production
target: 'es2015', // Optimize for modern browsers
reportCompressedSize: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'client/index.html')
},
output: {
assetFileNames: (assetInfo) => {
if (!assetInfo.name) return 'assets/[name][extname]';
if (/\.(woff2?|eot|ttf|otf)$/i.test(assetInfo.name)) {
return `assets/fonts/[name][extname]`;
}
if (/\.(css)$/i.test(assetInfo.name)) {
return `assets/css/[name][extname]`;
}
if (/\.(png|jpe?g|gif|svg|ico)$/i.test(assetInfo.name)) {
return `assets/images/[name][extname]`;
}
return `assets/[name][extname]`;
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
// Enable chunk size optimization
manualChunks(id) {
if (id.includes('node_modules')) {
// Group node_modules into vendor chunk
return 'vendor';
}
if (id.includes('three')) {
// Separate three.js into its own chunk
return 'three';
}
}
}
},
// Enable additional optimizations
terserOptions: isProd ? {
compress: {
drop_console: true,
drop_debugger: true
}
} : undefined
},
resolve: {
alias: {
'@': resolve(__dirname, './client')
}
},
server: {
port: 3001,
host: true,
proxy: {
'/wss': { // Updated from /ws to /wss to match nginx
target: 'ws://localhost:4000',
ws: true
},
'/api': {
target: 'http://localhost:4000',
changeOrigin: true
}
}
},
optimizeDeps: {
include: ['three']
},
define: {
__QUEST__: isQuest,
__DEV__: !isProd
}
};
});