-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
69 lines (64 loc) · 1.57 KB
/
vite.config.ts
File metadata and controls
69 lines (64 loc) · 1.57 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
67
68
69
/// <reference types="vitest" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { readFileSync } from "fs";
const pkg = JSON.parse(readFileSync("./package.json", "utf-8")) as {
version: string;
};
// Dynamic base path for GitHub Pages deployment
// In CI, extracts repository name from GITHUB_REPOSITORY (format: owner/repo-name)
// Falls back to "/" for local development
const getBasePath = () => {
if (process.env.NODE_ENV !== "production") {
return "/";
}
// In GitHub Actions, extract repo name from GITHUB_REPOSITORY
if (process.env.GITHUB_REPOSITORY) {
const repoName = process.env.GITHUB_REPOSITORY.split("/")[1];
return `/${repoName}/`;
}
// Fallback for local production builds
return "/package-compare/";
};
export default defineConfig({
plugins: [react()],
base: getBasePath(),
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
port: 3000,
open: true,
},
build: {
outDir: "dist",
sourcemap: true,
target: "esnext",
minify: "esbuild",
},
// vitest config
test: {
globals: true,
environment: "jsdom",
setupFiles: "./src/test/setup.tsx",
css: true,
exclude: ["**/node_modules/**", "**/e2e/**"],
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
exclude: [
"node_modules/",
"src/test/",
"**/*.d.ts",
"**/*.config.*",
"**/mockData",
],
},
},
});