Files
Netcatty/vite.config.ts
T
LAPTOP-O016UC3M\Qi Chen 0f20d4211d Improves WASM terminal error handling and CSP for web
Handles WASM initialization and terminal opening errors to
provide better diagnostics and reliability for the embedded
terminal. Updates content security policy and dev server
headers to support WASM and SharedArrayBuffer use, and
optimizes build config for proper WASM module loading.
2025-12-11 18:18:15 +08:00

38 lines
1.1 KiB
TypeScript
Executable File

import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig,loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '.', '');
return {
base: "./",
server: {
port: 5173,
host: '0.0.0.0',
headers: {
// Required for SharedArrayBuffer and WASM in some browsers
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
build: {
chunkSizeWarningLimit: 1500,
target: 'esnext', // Required for top-level await in WASM modules
},
plugins: [tailwindcss(), react()],
optimizeDeps: {
exclude: ['ghostty-web'], // Don't pre-bundle ghostty-web to preserve WASM imports
},
define: {
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
},
resolve: {
alias: {
'@': path.resolve(__dirname, '.'),
}
}
};
});