-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (62 loc) · 2.03 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (62 loc) · 2.03 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { execSync } from "node:child_process";
import { readFileSync, existsSync } from "node:fs";
import { resolve } from "node:path";
import { defineConfig, configDefaults } from "vitest/config";
import react from "@vitejs/plugin-react";
const mobileDevHost = process.env.TAURI_DEV_HOST;
const root = resolve(__dirname);
function resolveAppBuild(): string {
if (process.env.SKILLFORGE_BUILD?.trim()) return process.env.SKILLFORGE_BUILD.trim();
try {
return execSync("git rev-parse --short HEAD", { encoding: "utf8" }).trim();
} catch {
return "unknown";
}
}
/** Prefer RELEASE_LABEL (RepoPact 2.3 decision 0026); fall back to package.json. */
function resolveAppVersion(): string {
const labelPath = resolve(root, "RELEASE_LABEL");
if (existsSync(labelPath)) {
const label = readFileSync(labelPath, "utf8").trim();
if (label) return label;
}
const pkg = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8")) as { version?: string };
return pkg.version ?? "0.0.0";
}
export default defineConfig({
plugins: [react()],
clearScreen: false,
define: {
__APP_VERSION__: JSON.stringify(resolveAppVersion()),
__APP_BUILD__: JSON.stringify(resolveAppBuild())
},
server: {
host: mobileDevHost || false,
port: 1420,
strictPort: true,
hmr: mobileDevHost
? {
protocol: "ws",
host: mobileDevHost,
port: 1421
}
: undefined
},
envPrefix: ["VITE_", "TAURI_"],
// The Tauri build copies src/content (incl. test files) under src-tauri/target;
// keep the test runner out of those generated copies.
test: { exclude: [...configDefaults.exclude, "src-tauri/**"] },
build: {
target: ["es2021", "chrome100", "safari13"],
rolldownOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules/recharts") || id.includes("node_modules/d3-") ||
id.includes("node_modules/react-smooth") || id.includes("node_modules/decimal.js-light")) {
return "charts";
}
}
}
}
}
});