Files
DndGamePlayer/vite.config.ts
T
Ivan Fontosh 1ab6ffd593 feat(tokens): animated paths for scene and NPC tokens
Add path editor window, session playback on control/presentation, and RMB controls. Fix live pose clock so motion no longer freezes after ~250ms.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 08:48:41 +08:00

72 lines
2.6 KiB
TypeScript

import path from 'node:path';
import strip from '@rollup/plugin-strip';
import react from '@vitejs/plugin-react';
import { defineConfig, type Plugin } from 'vite';
/**
* Vite в проде вешает `crossorigin` на script/link; при открытии HTML через `file://` в Electron
* на Windows это часто приводит к тихому отказу загрузки ES-модулей (чёрный экран). macOS может «проглатывать».
*/
function stripCrossoriginForElectronFile(): Plugin {
return {
name: 'strip-crossorigin-electron-file',
enforce: 'post',
apply: 'build',
transformIndexHtml(html) {
return html.replace(/\s+crossorigin(?:=["']?[^"'>\s]+["']?)?/gi, '');
},
};
}
export default defineConfig(({ mode }) => {
const isProd = mode === 'production';
return {
/** Иначе в упакованном Electron `file://` запросы идут в `/assets/...` с корня диска — чёрный экран. */
base: isProd ? './' : '/',
root: path.resolve(__dirname, 'app/renderer'),
plugins: [
react({
babel: {
plugins: [['babel-plugin-react-compiler', { target: '19' }]],
},
} as Parameters<typeof react>[0]),
...(isProd ? [stripCrossoriginForElectronFile()] : []),
],
build: {
outDir: path.resolve(__dirname, 'dist/renderer'),
emptyOutDir: true,
sourcemap: !isProd,
rollupOptions: {
plugins: isProd
? [
strip({
sourceMap: false,
debugger: true,
functions: ['console.*', 'assert.*'],
}),
]
: [],
input: {
boot: path.resolve(__dirname, 'app/renderer/boot.html'),
editor: path.resolve(__dirname, 'app/renderer/editor.html'),
presentation: path.resolve(__dirname, 'app/renderer/presentation.html'),
control: path.resolve(__dirname, 'app/renderer/control.html'),
sceneDescription: path.resolve(__dirname, 'app/renderer/sceneDescription.html'),
materials: path.resolve(__dirname, 'app/renderer/materials.html'),
sceneEditor: path.resolve(__dirname, 'app/renderer/sceneEditor.html'),
tokenPathEditor: path.resolve(__dirname, 'app/renderer/tokenPathEditor.html'),
npcsEditor: path.resolve(__dirname, 'app/renderer/npcsEditor.html'),
npcs: path.resolve(__dirname, 'app/renderer/npcs.html'),
},
},
},
server: {
host: '127.0.0.1',
port: 5173,
strictPort: true,
},
};
});