-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
60 lines (56 loc) · 1.5 KB
/
vite.config.ts
File metadata and controls
60 lines (56 loc) · 1.5 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
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import honox from "honox/vite";
import ssg from "@hono/vite-ssg";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// GitHub Pages base path (set via environment variable or default to root)
const base = process.env.BASE_PATH ?? "/";
export default defineConfig(({ mode }) => {
// Client build (CSS + JS)
if (mode === "client") {
return {
base,
build: {
rollupOptions: {
input: ["/app/style.css", "/app/client.ts"],
output: {
entryFileNames: "static/[name].js",
assetFileNames: "static/[name][extname]",
},
},
outDir: "dist",
emptyOutDir: false,
manifest: true,
},
};
}
// SSG build (default)
return {
base,
build: {
emptyOutDir: false, // Don't overwrite client build assets
},
plugins: [
honox({
client: {
input: ["/app/style.css", "/app/client.ts"],
},
devServer: {
// Pass base path to @hono/vite-dev-server to fix import.meta.env.BASE_URL
base,
},
}),
ssg({ entry: "./app/server.ts" }),
],
resolve: {
alias: {
// @tabler/icons doesn't export JSON files by default
"@tabler/icons/tabler-nodes-outline.json": path.resolve(
__dirname,
"node_modules/@tabler/icons/tabler-nodes-outline.json"
),
},
},
};
});