659affa88c
vitest@4.1.4 requires vite ^6||^7||^8. With vite@6 at project level, npm@10 installs a separate vite@8 for vitest, which pulls in rolldown (native .node bindings) that npm ci cannot install cross-platform due to npm bug #4828. vite@7 avoids rolldown entirely (uses rollup) and npm@10 deduplicates correctly with the project-level vite@7. Also adds esbuild@^0.27.0 explicitly (required by vite-plugin-electron-renderer) and aligns with vite@7's own esbuild@^0.27.0 so no duplicate installs. - vite: ^6.4.2 → ^7.3.2 - @vitejs/plugin-react: ^4.7.0 → ^5.2.0 (adds vite@7/8 support) - esbuild: ^0.27.0 added explicitly - vite.config.ts: manualChunks converted to function form (rollup compat)
66 lines
1.7 KiB
TypeScript
66 lines
1.7 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: {
|
|
// Shortcut of `build.lib.entry`.
|
|
entry: "electron/main.ts",
|
|
vite: {
|
|
build: {},
|
|
},
|
|
},
|
|
preload: {
|
|
// Shortcut of `build.rollupOptions.input`.
|
|
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
|
|
input: path.join(__dirname, "electron/preload.ts"),
|
|
},
|
|
// Ployfill the Electron and Node.js API for Renderer process.
|
|
// If you want use Node.js in Renderer process, the `nodeIntegration` needs to be enabled in the Main process.
|
|
// See https://github.com/electron-vite/vite-plugin-electron-renderer
|
|
renderer:
|
|
process.env.NODE_ENV === "test"
|
|
? // https://github.com/electron-vite/vite-plugin-electron-renderer/issues/78#issuecomment-2053600808
|
|
undefined
|
|
: {},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "src"),
|
|
},
|
|
},
|
|
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,
|
|
},
|
|
});
|