Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
41 lines (38 loc) · 1.39 KB
/
Copy pathvite.config.ts
File metadata and controls
41 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { execFileSync } from "node:child_process";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { devCsp } from "./src/dev-csp";
import { buildSha } from "./src/dev/buildSha";
// `TAURI_DEV_HOST` is set by the Tauri CLI when developing against a device on
// the local network. Everything else is a plain Vite setup.
const host = process.env.TAURI_DEV_HOST;
function gitSha() {
try { return execFileSync("git", ["rev-parse", "--short", "HEAD"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim(); }
catch { return undefined; }
}
export default defineConfig({
define: {
__BUILD_SHA__: JSON.stringify(buildSha(process.env.GITHUB_SHA, process.env.GITHUB_SHA ? undefined : gitSha())),
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
},
plugins: [react(), devCsp()],
// Tauri's CLI owns the terminal output during `tauri dev`.
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host ?? false,
hmr: host ? { protocol: "ws", host, port: 1421 } : undefined,
watch: {
// The Rust core is watched by cargo, not by Vite.
ignored: ["**/src-tauri/**"],
},
},
build: {
outDir: "dist",
target: "esnext",
// Keine Sourcemaps im Produktions-Bundle: der NSIS-Installer wird über das
// öffentliche Mirror-Repo verteilt, der Quellcode bleibt privat.
sourcemap: false,
},
});