2025-12-07 19:32:53 +02:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
|
import path from 'node:path';
|
|
|
|
|
import { fileURLToPath } from 'node:url';
|
2025-12-19 18:59:08 +02:00
|
|
|
import { readFileSync } from 'node:fs';
|
2025-12-07 19:32:53 +02:00
|
|
|
import { themeStoragePlugin } from '../../vite-theme-plugin';
|
|
|
|
|
|
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
2025-12-19 18:59:08 +02:00
|
|
|
const packageJson = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8'));
|
2025-12-07 19:32:53 +02:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
root: path.resolve(__dirname, '.'),
|
|
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
themeStoragePlugin(),
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
2026-01-03 13:39:59 +02:00
|
|
|
alias: [
|
|
|
|
|
{ find: '@opencode-ai/sdk/v2', replacement: path.resolve(__dirname, '../../node_modules/@opencode-ai/sdk/dist/v2/client.js') },
|
|
|
|
|
{ find: '@openchamber/ui', replacement: path.resolve(__dirname, '../ui/src') },
|
|
|
|
|
{ find: '@web', replacement: path.resolve(__dirname, './src') },
|
|
|
|
|
{ find: '@', replacement: path.resolve(__dirname, '../ui/src') },
|
|
|
|
|
],
|
2025-12-07 19:32:53 +02:00
|
|
|
},
|
2026-01-02 21:57:53 +02:00
|
|
|
worker: {
|
|
|
|
|
format: 'es',
|
|
|
|
|
},
|
2025-12-07 19:32:53 +02:00
|
|
|
define: {
|
|
|
|
|
'process.env': {},
|
|
|
|
|
global: 'globalThis',
|
2025-12-19 18:59:08 +02:00
|
|
|
__APP_VERSION__: JSON.stringify(packageJson.version),
|
2025-12-07 19:32:53 +02:00
|
|
|
},
|
|
|
|
|
optimizeDeps: {
|
2026-01-03 13:39:59 +02:00
|
|
|
include: ['@opencode-ai/sdk/v2'],
|
2025-12-07 19:32:53 +02:00
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://127.0.0.1:3001',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
outDir: path.resolve(__dirname, 'dist'),
|
|
|
|
|
emptyOutDir: true,
|
|
|
|
|
chunkSizeWarningLimit: 1200,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
external: ['node:child_process', 'node:fs', 'node:path', 'node:url'],
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks(id) {
|
|
|
|
|
if (!id.includes('node_modules')) return undefined;
|
|
|
|
|
|
|
|
|
|
const match = id.split('node_modules/')[1];
|
|
|
|
|
if (!match) return undefined;
|
|
|
|
|
|
|
|
|
|
const segments = match.split('/');
|
|
|
|
|
const packageName = match.startsWith('@') ? `${segments[0]}/${segments[1]}` : segments[0];
|
|
|
|
|
|
|
|
|
|
if (packageName === 'react' || packageName === 'react-dom') return 'vendor-react';
|
|
|
|
|
if (packageName === 'zustand' || packageName === 'zustand/middleware') return 'vendor-zustand';
|
|
|
|
|
|
|
|
|
|
if (packageName === '@opencode-ai/sdk') return 'vendor-opencode-sdk';
|
|
|
|
|
if (packageName.includes('remark') || packageName.includes('rehype') || packageName === 'react-markdown') return 'vendor-markdown';
|
|
|
|
|
if (packageName.startsWith('@radix-ui')) return 'vendor-radix';
|
|
|
|
|
if (packageName.includes('react-syntax-highlighter') || packageName.includes('highlight.js')) return 'vendor-syntax';
|
|
|
|
|
|
|
|
|
|
const sanitized = packageName.replace(/^@/, '').replace(/\//g, '-');
|
|
|
|
|
return `vendor-${sanitized}`;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|