-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvite.config.ts
More file actions
126 lines (125 loc) · 4.11 KB
/
vite.config.ts
File metadata and controls
126 lines (125 loc) · 4.11 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
/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import wasm from 'vite-plugin-wasm';
import path from 'path';
export default defineConfig({
// Relative base so the SPA works both at domain root (rosview.com) and under a path prefix (io-ai.tech/rosview/).
base: './',
test: {
environment: 'node',
include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
coverage: {
provider: 'v8',
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.test.{ts,tsx}',
'src/**/*.worker.ts',
'src/entrypoints/main.tsx',
'src/entrypoints/App.tsx',
],
reporter: ['text', 'lcov'],
thresholds: {
lines: 50,
functions: 50,
},
},
},
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
assetsInclude: ['**/*.wasm'],
server: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "credentialless",
},
},
preview: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "credentialless",
},
},
optimizeDeps: {
// Playback workers are imported only after a dataset is opened. Pre-bundle their
// transitive parser/decompression deps up front so first-open in dev does not
// trigger Vite's "new dependencies optimized" reload and bounce back to home.
include: [
'@foxglove/omgidl-parser',
'@foxglove/omgidl-serialization',
'@foxglove/ros2idl-parser',
'@foxglove/rosmsg',
'@foxglove/rosmsg-serialization',
'@foxglove/rosmsg2-serialization',
'@ioai/wasm-zstd',
'@mcap/browser',
'@mcap/core',
'eventemitter3',
'flatbuffers/js/flexbuffers.js',
'intervals-fn',
'lz4js',
'protobufjs',
'protobufjs/ext/descriptor',
'@ioai/hdf5',
],
},
worker: {
format: 'es',
plugins: () => [wasm()],
rolldownOptions: {
onLog(level, log, defaultHandler) {
if (level === 'warn' && typeof log !== 'string') {
const paths = [log.id, log.loc?.file, ...(log.ids ?? [])].filter(Boolean) as string[];
const inNodeModules = paths.some((p) => p.includes('/node_modules/'));
const isViteResolveWarn =
log.plugin === 'rolldown:vite-resolve' && log.message.includes('node_modules');
if (inNodeModules || isViteResolveWarn) return;
}
defaultHandler(level, log);
},
output: {
format: 'es',
// @ioai/hdf5 dynamic import must stay in the worker bundle — splitting it
// emits a sibling chunk (dist-*.js) that workers resolve with a broken
// relative URL under preview/assets/.
codeSplitting: false,
},
},
},
build: {
target: 'esnext',
chunkSizeWarningLimit: 1200,
rolldownOptions: {
checks: {
// The worker-heavy build legitimately spends time in Vite worker/CSS plugins;
// keep chunk-size warnings meaningful without failing on plugin timing noise.
pluginTimings: false,
},
onLog(level, log, defaultHandler) {
if (level === 'warn' && typeof log !== 'string') {
const paths = [log.id, log.loc?.file, ...(log.ids ?? [])].filter(Boolean) as string[];
const inNodeModules = paths.some((p) => p.includes('/node_modules/'));
const isViteResolveWarn =
log.plugin === 'rolldown:vite-resolve' && log.message.includes('node_modules');
if (inNodeModules || isViteResolveWarn) return;
}
defaultHandler(level, log);
},
output: {
codeSplitting: true,
manualChunks(id) {
if (id.includes('dockview')) return 'vendor-dockview';
if (id.includes('three')) return 'vendor-three';
if (id.includes('uplot')) return 'vendor-uplot';
if (id.includes('@mcap/core')) return 'vendor-mcap';
if (id.includes('@foxglove/rosbag')) return 'vendor-rosbag';
if (id.includes('@ioai/hdf5')) return 'vendor-ioai-hdf5';
},
},
},
},
});