-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
74 lines (71 loc) · 2.15 KB
/
Copy pathvite.config.js
File metadata and controls
74 lines (71 loc) · 2.15 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
import { rmSync } from 'node:fs'
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
// The 10 UI bake-off mockups live in `public/mockups/` so they stay in git as
// the canonical visual reference (see docs/FIELD_JOURNAL_UI.md) and remain
// viewable on the dev server at /mockups/. They are NOT product, though, so we
// strip the directory from `dist/` after the bundle is written — the prod
// deploy carries zero mockup bytes (Field Journal direction 03 won 2026-06-03).
function stripMockupsFromBuild() {
let outDir = 'dist'
return {
name: 'strip-mockups-from-build',
apply: 'build',
configResolved(config) {
outDir = config.build.outDir
},
closeBundle() {
rmSync(resolve(import.meta.dirname, outDir, 'mockups'), {
recursive: true,
force: true
})
}
}
}
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
plugins: [stripMockupsFromBuild()],
// Route @recast-navigation/wasm to its non-compat entry so the WASM binary
// ships as one content-hashed asset shared across the main and navmesh
// worker graphs. The compat variant inlined the binary as base64, which
// produced a ~710kB loader chunk duplicated per Vite worker boundary
// (~1.4MB raw / ~425KB gzip). With this alias the duplication collapses
// to a ~275kB Emscripten loader JS per graph plus a single ~340kB .wasm
// asset -- net savings ~540kB raw / ~210kB gzipped.
resolve: {
alias: {
'@recast-navigation/wasm': '@recast-navigation/wasm/wasm'
}
},
optimizeDeps: {
entries: ['index.html']
},
server: {
watch: {
ignored: ['**/artifacts/**']
}
},
build: {
outDir: 'dist',
assetsDir: 'build-assets',
target: 'es2020',
reportCompressedSize: true,
sourcemap: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('three-mesh-bvh')) return 'bvh'
if (id.includes('three')) return 'three'
}
if (id.includes('/src/ui/')) return 'ui'
}
}
}
},
assetsInclude: ['**/*.glsl'],
worker: {
format: 'es'
}
})