Files
aryx/electron.vite.config.ts
T
David KayaandCopilot 4f202274db feat: replace PrismJS with highlight.js for code syntax highlighting
PrismJS's CJS global state is fundamentally incompatible with Vite's ESM
dev mode, causing missing language support (~40% of dropdown languages)
and fragile loading hacks (optimizeDeps, global assignment).

Replace the entire Prism integration with highlight.js/lib/common which
is ESM-native, has no global state, and covers all 22 dropdown languages
out of the box (~37 common languages included).

Implementation:
- Custom CodeHighlightPlugin using hljs.highlight() for tokenization
- HTML parser extracts flat tokens from hljs output (handles nested spans)
- Token type mapping from hljs scopes to Lexical codeHighlight theme keys
- Selection preservation via absolute character offset save/restore
- Re-entrancy guard prevents infinite transform loops
- Removed @lexical/code-prism import and Vite optimizeDeps workaround

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-25 20:08:14 +01:00

45 lines
995 B
TypeScript

import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
export default defineConfig({
main: {
build: {
outDir: 'dist-electron/main',
},
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@main': resolve(__dirname, 'src/main'),
'@shared': resolve(__dirname, 'src/shared'),
},
},
},
preload: {
build: {
outDir: 'dist-electron/preload',
},
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@shared': resolve(__dirname, 'src/shared'),
},
},
},
renderer: {
root: 'src/renderer',
build: {
outDir: 'dist/renderer',
},
plugins: [react(), tailwindcss()],
resolve: {
alias: {
'@renderer': resolve(__dirname, 'src/renderer'),
'@shared': resolve(__dirname, 'src/shared'),
},
},
},
});