react-ace v14 is CommonJS-only with no ESM entry point, making it fundamentally incompatible with Vite's ESM-first dev server. Every CJS interop workaround failed. Switched to @uiw/react-codemirror v4.25 which ships proper dual ESM+CJS and works with Vite out of the box. Changes: - Remove ace-builds and react-ace dependencies - Add @uiw/react-codemirror + 16 @codemirror/lang-* packages - Add @uiw/codemirror-theme-tomorrow-night-blue (closest to ACE's 'tomorrow') - Add @replit/codemirror-lang-csharp for C# support - Rewrite EditorPanel.tsx: delete 108 lines of ACE boilerplate (?url imports, setModuleUrl, CJS interop hack), replace with ~30 lines of clean CodeMirror language extension setup - Delete vite.d.ts (only needed for ACE ?url import types) - Remove optimizeDeps.include from vite.config.ts (not needed for CM) - Add CodeMirror flex layout CSS to index.css Supported languages: JavaScript/JSX, TypeScript/TSX, Python, JSON, HTML, CSS, Less, YAML, Markdown, SQL, Java, Go, Rust, C/C++, C#, PHP, XML. Unsupported types fall back to plain text. Verified: tsc clean, vite build passes, heartbeat worker intact.
78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'node:path';
|
|
import fs from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const rootDir = path.resolve(__dirname, '..');
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
root: '.',
|
|
publicDir: 'public',
|
|
server: {
|
|
port: 5174,
|
|
host: '0.0.0.0',
|
|
https: (() => {
|
|
const keyPath = path.join(rootDir, 'ssl', 'code-dev.g4dge7.com.key');
|
|
const certPath = path.join(rootDir, 'ssl', 'code-dev.g4dge7.com.crt');
|
|
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
|
|
return {
|
|
key: fs.readFileSync(keyPath),
|
|
cert: fs.readFileSync(certPath),
|
|
};
|
|
}
|
|
return undefined;
|
|
})(),
|
|
hmr: {
|
|
host: 'code-dev.g4dge7.com',
|
|
port: 5174,
|
|
protocol: 'wss',
|
|
},
|
|
proxy: {
|
|
'/auth': {
|
|
target: 'http://localhost:3443',
|
|
changeOrigin: true,
|
|
cookieDomainRewrite: {
|
|
'': 'code-dev.g4dge7.com',
|
|
},
|
|
},
|
|
'/api': {
|
|
target: 'http://localhost:3443',
|
|
changeOrigin: true,
|
|
cookieDomainRewrite: {
|
|
'': 'code-dev.g4dge7.com',
|
|
},
|
|
},
|
|
'/socket.io': {
|
|
target: 'http://localhost:3443',
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: path.join(rootDir, 'dist', 'client'),
|
|
emptyOutDir: true,
|
|
rolldownOptions: {
|
|
output: {
|
|
codeSplitting: {
|
|
minSize: 20000,
|
|
groups: [
|
|
{
|
|
name: 'vendor',
|
|
test: /[\\/]node_modules[\\/]/,
|
|
priority: 10,
|
|
maxSize: 250000,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.join(rootDir, 'src'),
|
|
},
|
|
},
|
|
}); |