-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
175 lines (150 loc) · 5.22 KB
/
Copy pathvite.config.ts
File metadata and controls
175 lines (150 loc) · 5.22 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
optimizeDeps: {
// Keep Photons2 out of the dev prebundle so its `three` import goes
// through the same alias/dedupe path as the rest of the app.
exclude: ['photons2'],
},
resolve: {
dedupe: ['three'],
alias: [
{
find: /^three$/,
replacement: fileURLToPath(new URL('./src/vendor/three-compat.ts', import.meta.url)),
},
],
},
build: {
// Map data is already split per-level and lazy-loaded. Keep the warning
// high enough to avoid noise from those intentional JSON-heavy chunks
// while still catching a meaningful regression above today's largest one.
chunkSizeWarningLimit: 800,
rollupOptions: {
output: {
manualChunks(id) {
const normalizedId = id.replace(/\\/g, '/')
if (normalizedId.includes('/node_modules/')) {
if (
normalizedId.includes('/three/')
) {
return 'three-core'
}
if (normalizedId.includes('/photons2/')) {
return 'photons-vendor'
}
if (normalizedId.includes('/@react-three/')) {
return 'three-r3f'
}
if (
normalizedId.includes('/framer-motion/') ||
normalizedId.includes('/lucide-react/')
) {
return 'ui-vendor'
}
return 'vendor'
}
if (
normalizedId.includes('/src/assets/runtime/dungeon/bootstrap.json')
) {
return 'dungeon-bootstrap'
}
if (
normalizedId.includes('/src/assets/runtime/db/game_db_items.json')
) {
return 'game-db-items'
}
if (
normalizedId.includes('/src/assets/runtime/db/game_db_weapon_attacks.json')
) {
return 'game-db-weapon-attacks'
}
if (
normalizedId.includes('/src/assets/runtime/db/game_db_creatures.json')
) {
return 'game-db-creatures'
}
if (
normalizedId.includes('/src/assets/runtime/db/game_db.json')
) {
return 'game-db-legacy'
}
if (
normalizedId.includes('/src/assets/runtime/dungeon/maps/')
) {
return undefined
}
if (
normalizedId.includes('/src/assets/runtime/reference/') ||
normalizedId.includes('/src/data/dungeonData.ts') ||
normalizedId.includes('/src/data/gameDbData.ts') ||
normalizedId.includes('/src/data/mapLoader.ts')
) {
return 'boot-data'
}
if (
normalizedId.includes('/src/data/items.ts') ||
normalizedId.includes('/src/data/itemImages.ts') ||
normalizedId.includes('/src/data/waterContainers.ts') ||
normalizedId.includes('/src/data/weaponAttacks.ts')
) {
return 'runtime-data-core'
}
if (
normalizedId.includes('/src/data/runes.ts') ||
normalizedId.includes('/src/data/originalSpells.ts') ||
normalizedId.includes('/src/data/spells.ts') ||
normalizedId.includes('/src/data/spellRuntime.ts')
) {
return 'magic-data'
}
if (normalizedId.includes('/src/data/assetPaths.ts')) {
return 'asset-runtime'
}
if (
normalizedId.includes('/src/assets/runtime/support/original_wall_overlay_positions.json') ||
normalizedId.includes('/src/data/originalWallOverlays.ts')
) {
return 'overlay-data'
}
if (
normalizedId.includes('/src/data/champions.ts') ||
normalizedId.includes('/src/data/championStarterItems.ts') ||
normalizedId.includes('/src/data/creatures.ts') ||
normalizedId.includes('/src/data/mechanisms.ts') ||
normalizedId.includes('/src/data/equipment.ts') ||
normalizedId.includes('/src/data/doors.ts')
) {
return 'runtime-data-core'
}
if (
normalizedId.includes('/src/engine/saveGame.ts') ||
normalizedId.includes('/src/engine/sounds.ts')
) {
return 'runtime-data-core'
}
if (normalizedId.includes('/src/components/Dungeon/PhotonsFireball.tsx')) {
return 'dungeon-effects'
}
if (normalizedId.includes('/src/components/UI/HUD.tsx')) {
return 'hud-ui'
}
if (normalizedId.includes('/src/components/UI/ChampionSheet.tsx')) {
return 'champion-sheet'
}
if (normalizedId.includes('/src/components/UI/MirrorPopup.tsx')) {
return 'mirror-popup'
}
if (normalizedId.includes('/src/components/UI/VictoryScreen.tsx')) {
return 'victory-screen'
}
if (normalizedId.includes('/src/components/Dungeon/')) {
return 'dungeon-render'
}
},
},
},
},
})