-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (62 loc) · 2.09 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (62 loc) · 2.09 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { readFileSync } from 'fs';
import { resolve } from 'path';
// Read root package.json for app version
const rootPackageJson = JSON.parse(
readFileSync(resolve(__dirname, '../../package.json'), 'utf-8')
);
const appVersion = rootPackageJson.version;
const base = process.env.VITE_BASE_URL
? process.env.VITE_BASE_URL.endsWith('/')
? process.env.VITE_BASE_URL
: `${process.env.VITE_BASE_URL}/`
: '/';
// In dev mode, resolve workspace packages to their source files
// This allows hot-reload without needing to rebuild packages
const isDev = process.env.NODE_ENV !== 'production';
const packagesPath = resolve(__dirname, '../../packages');
// https://vitejs.dev/config/
export default defineConfig({
plugins: [tailwindcss(), react()],
resolve: {
alias: {
// In dev mode, resolve @fluxby/* packages to source files for hot-reload
...(isDev && {
'@fluxby/shared': resolve(packagesPath, 'shared/src/index.ts'),
}),
},
},
server: {
port: 5177, // Landing page port
// Headers required for SharedArrayBuffer (needed for SQLite WASM in the proxied /app)
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
proxy: {
// Proxy /app to the web app dev server
// The web app is configured with base: '/app/' so we forward requests directly
'/app': {
target: 'http://localhost:5178',
changeOrigin: true,
// Enable WebSocket proxy for Vite HMR (Hot Module Replacement)
// Without this, CSS updates via HMR won't work when accessing /app through the proxy
ws: true,
},
// Proxy API calls for developers building their own interfaces
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
},
base, // Dynamic base path for deployment (GitHub Pages)
define: {
__APP_VERSION__: JSON.stringify(appVersion),
},
});