-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathvite.config.ts
More file actions
115 lines (105 loc) · 3.22 KB
/
Copy pathvite.config.ts
File metadata and controls
115 lines (105 loc) · 3.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
import { lingui } from '@lingui/vite-plugin'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import react from '@vitejs/plugin-react'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config'
const isTest = process.env.NODE_ENV === 'test' || process.env.VITEST
const isDev = process.env.NODE_ENV === 'development'
export default defineConfig({
plugins: [
react({
babel: {
plugins: [
// Skip lingui macros in test - we mock @lingui/macro directly
...(!isTest ? ['macros'] : []),
// Only include locator in development - breaks React internals in prod
...(isDev
? [['@locator/babel-jsx/dist', { env: 'development' }]]
: []),
],
},
}),
// Skip lingui plugin in test - interferes with vi.mock
...(!isTest ? [lingui()] : []),
viteTsconfigPaths(), // Resolves tsconfig paths (@/, utils/, etc.)
viteStaticCopy({
targets: [
{
src: 'node_modules/@reserve-protocol/rtokens/images/*',
dest: 'svgs',
},
{ src: '_headers', dest: '' }, // Cloudflare security headers
],
}),
sentryVitePlugin({ org: 'abc-labs-0g', project: 'register' }),
],
define: {
'import.meta.env.VITE_GIT_SHA': JSON.stringify(
process.env.CF_PAGES_COMMIT_SHA
),
},
build: {
outDir: 'build',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: (id) => {
if (!id.includes('node_modules')) return undefined
// Wallet stack: ~4MB self-contained chunk
// These packages form a cohesive unit and don't import from app code
if (
id.includes('/wagmi/') ||
id.includes('/@wagmi/') ||
id.includes('/viem/') ||
id.includes('/@rainbow-me/rainbowkit') ||
id.includes('/@walletconnect/') ||
id.includes('/@coinbase/wallet-sdk') ||
id.includes('/@reown/')
) {
return 'wallet'
}
// Let Vite handle everything else to avoid circular deps
return undefined
},
},
},
},
// tsconfig paths are handled by viteTsconfigPaths; keep runtime-only aliases here.
resolve: {
alias: {
// Polyfill for @cowprotocol/cow-sdk
'node-fetch': 'cross-fetch',
},
dedupe: ['react', 'react-dom', '@tanstack/react-query'],
},
optimizeDeps: {
// Linked local package — serve its TSX source directly (don't pre-bundle a
// symlinked workspace dep). React is deduped above so the widget's hooks
// resolve to Register's single React instance.
exclude: ['ts-node', '@reserve-protocol/dtf-chat'],
include: [
'react',
'react-dom',
'react-router-dom',
'ai',
'@ai-sdk/react',
'@radix-ui/react-accordion',
'@radix-ui/react-dialog',
'@radix-ui/react-select',
'@radix-ui/react-tabs',
],
},
server: {
port: 3000,
},
test: {
include: [
'src/**/tests/**/*.test.{ts,tsx}',
'e2e/helpers/tests/**/*.test.ts',
],
globals: true,
environment: 'jsdom',
setupFiles: ['./src/setup-tests.ts'],
},
})