Files
openchamber/packages/vscode/vite.config.ts
T

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-12-13 16:34:17 +02:00
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
root: path.resolve(__dirname, 'webview'),
base: './', // Use relative paths for VS Code webview
plugins: [
react({
babel: {
plugins: ['babel-plugin-react-compiler'],
},
}),
],
2025-12-13 16:34:17 +02:00
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: '@vscode', replacement: path.resolve(__dirname, './webview') },
{ find: '@', replacement: path.resolve(__dirname, '../ui/src') },
],
2025-12-13 16:34:17 +02:00
},
worker: {
format: 'es',
},
2025-12-13 16:34:17 +02:00
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
'global': 'globalThis',
2026-01-06 21:31:04 +02:00
'__OPENCHAMBER_WEBVIEW_BUILD_TIME__': JSON.stringify(new Date().toISOString()),
2025-12-13 16:34:17 +02:00
},
envPrefix: ['VITE_'],
optimizeDeps: {
2026-01-03 13:39:59 +02:00
include: ['@opencode-ai/sdk/v2'],
2025-12-13 16:34:17 +02:00
},
build: {
outDir: path.resolve(__dirname, 'dist/webview'),
emptyOutDir: true,
rollupOptions: {
input: path.resolve(__dirname, 'webview/index.html'),
external: ['node:child_process', 'node:fs', 'node:path', 'node:url'],
output: {
entryFileNames: 'assets/[name].js',
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]',
},
},
},
});