waveterm/electron.vite.config.ts
Evan Simkowitz 6400678686
Upgrade Vite and other deps to resolve packaging issue (#1387)
There was a bug in Vite 6.0.1
(https://github.com/vitejs/vite/issues/18810) that was preventing NodeJS
libraries from being bundled in the main process. This meant that our
packaged app would refuse to run as it would be unable to find its Node
libraries.

This updates to Vite 6.0.2 to resolve this issue and also updates a few
other deps while we're at it.

Also removes the SASS modern-compiler config from our Vite config since
this is the default behavior in Vite 6.

closes #1373
2024-12-04 16:22:53 -08:00

88 lines
2.3 KiB
TypeScript

// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "electron-vite";
import flow from "rollup-plugin-flow";
import { ViteImageOptimizer } from "vite-plugin-image-optimizer";
import { viteStaticCopy } from "vite-plugin-static-copy";
import svgr from "vite-plugin-svgr";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({
main: {
root: ".",
build: {
rollupOptions: {
input: {
index: "emain/emain.ts",
},
},
outDir: "dist/main",
},
plugins: [tsconfigPaths(), flow()],
resolve: {
alias: {
"@": "frontend",
},
},
define: {
"process.env.WS_NO_BUFFER_UTIL": "true",
"process.env.WS_NO_UTF_8_VALIDATE": "true",
},
},
preload: {
root: ".",
build: {
sourcemap: true,
rollupOptions: {
input: {
index: "emain/preload.ts",
"preload-webview": "emain/preload-webview.ts",
},
output: {
format: "cjs",
},
},
outDir: "dist/preload",
},
plugins: [tsconfigPaths(), flow()],
},
renderer: {
root: ".",
build: {
target: "es6",
sourcemap: true,
outDir: "dist/frontend",
rollupOptions: {
input: {
index: "index.html",
},
},
},
server: {
open: false,
},
plugins: [
ViteImageOptimizer(),
tsconfigPaths(),
svgr({
svgrOptions: { exportType: "default", ref: true, svgo: false, titleProp: true },
include: "**/*.svg",
}),
react({}),
flow(),
viteStaticCopy({
targets: [{ src: "node_modules/monaco-editor/min/vs/*", dest: "monaco" }],
}),
],
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler", // or "modern"
},
},
},
},
});