mirror of
https://github.com/siddharthvaddem/openscreen.git
synced 2026-08-29 03:08:30 +08:00
e5462f1ac8
Move model load and transcription off the renderer main thread into a dedicated worker (transcribe.worker.ts + transcribeCore.ts) so the editor UI no longer freezes during captioning. Relocate the auto-captions action from the editor header into the timeline toolbar, and add the missing it/pt-BR/ru/vi autoCaptions translations.
75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
import path from "node:path";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
import electron from "vite-plugin-electron/simple";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
electron({
|
|
main: {
|
|
entry: "electron/main.ts",
|
|
onstart({ startup }) {
|
|
const env = { ...process.env };
|
|
delete env.ELECTRON_RUN_AS_NODE;
|
|
return startup(["."], { env });
|
|
},
|
|
vite: {
|
|
build: {},
|
|
},
|
|
},
|
|
preload: {
|
|
input: path.join(__dirname, "electron/preload.ts"),
|
|
},
|
|
renderer: process.env.NODE_ENV === "test" ? undefined : {},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "src"),
|
|
// @xenova/transformers: env.js statically imports fs/path/url; onnx.js imports
|
|
// onnxruntime-node (must not be bundled in the renderer — it requires fs).
|
|
fs: path.resolve(__dirname, "src/lib/vite-stubs/empty-node-module.ts"),
|
|
path: path.resolve(__dirname, "src/lib/vite-stubs/empty-node-module.ts"),
|
|
url: path.resolve(__dirname, "src/lib/vite-stubs/empty-node-module.ts"),
|
|
"onnxruntime-node": path.resolve(__dirname, "src/lib/vite-stubs/onnxruntime-node-stub.ts"), // re-exports web ORT
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
exclude: ["@xenova/transformers"],
|
|
},
|
|
// The captioning worker dynamically imports @xenova/transformers, which makes the
|
|
// worker bundle code-split — unsupported by the default "iife" worker format.
|
|
worker: {
|
|
format: "es",
|
|
},
|
|
build: {
|
|
target: "esnext",
|
|
minify: "terser",
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
pure_funcs: ["console.log", "console.debug"],
|
|
},
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes("pixi.js") || id.includes("pixi-filters") || id.includes("@pixi/"))
|
|
return "pixi";
|
|
if (id.includes("react-dom") || id.includes("/react/")) return "react-vendor";
|
|
if (
|
|
id.includes("mediabunny") ||
|
|
id.includes("mp4box") ||
|
|
id.includes("fix-webm-duration")
|
|
)
|
|
return "video-processing";
|
|
},
|
|
},
|
|
},
|
|
chunkSizeWarningLimit: 1000,
|
|
},
|
|
});
|