-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
48 lines (46 loc) · 1.57 KB
/
Copy pathvite.config.ts
File metadata and controls
48 lines (46 loc) · 1.57 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
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { cspMetaPlugin } from './src/buildtime/csp';
export default defineConfig(({ command, isPreview }) => ({
base: command === 'serve' && !isPreview ? '/' : '/cpap-analyzer/',
plugins: [react(), tsconfigPaths(), cspMetaPlugin()],
build: {
target: 'es2020',
assetsInlineLimit: 0,
rollupOptions: {
output: {
manualChunks(id) {
if (
id.includes('node_modules/react-dom') ||
id.includes('node_modules/react/') ||
id.includes('node_modules/react-router-dom')
) {
return 'vendor';
}
if (id.includes('node_modules/recharts')) {
return 'recharts';
}
if (id.includes('node_modules/d3')) {
return 'd3';
}
// AI Insights provider SDKs (ADR 0024). These are only ever reached
// via dynamic import() inside the provider methods, so they already
// code-split into async chunks; naming them keeps each SDK in its own
// isolated chunk (well clear of the main bundle) and makes the split
// explicit/auditable rather than incidental.
if (id.includes('node_modules/@anthropic-ai/sdk')) {
return 'llm-anthropic';
}
if (id.includes('node_modules/@mlc-ai/web-llm')) {
return 'llm-webllm';
}
},
},
},
},
worker: {
format: 'es',
plugins: () => [tsconfigPaths()],
},
}));