-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
64 lines (62 loc) · 1.75 KB
/
vite.config.ts
File metadata and controls
64 lines (62 loc) · 1.75 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
import path from "node:path";
import devServer from "@hono/vite-dev-server";
import bunAdapter from "@hono/vite-dev-server/bun";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { preventImports } from "./vite-plugins";
export default defineConfig(({ command }) => {
const resolveConfig = {
alias: {
"@": path.resolve(__dirname, "."),
"~": path.resolve(__dirname, "./web"),
},
};
return {
resolve: resolveConfig,
build: {
minify: true,
ssr: true, // Optimizes for Bun/Node
outDir: "dist-server", // Server builds to dist-server
emptyOutDir: true, // Clean the server output folder
rollupOptions: {
input: "./server/server.ts",
output: {
entryFileNames: "_worker.js",
},
},
},
server: {
watch: {
ignored: ["**/.direnv/**", "**/.git/**", "**/node_modules/**"],
},
},
optimizeDeps: {
entries: ["./web/client.ts", "./web/app.tsx"],
},
plugins: [
// Do not allow server code to be imported into the client build
preventImports({
fromFolder: path.resolve(__dirname, "web"),
folder: path.resolve(__dirname, "server"),
// For the Hono RPC to work correctly, we need to allow types to be
// imported from `server.ts` to the client code.
ignores: ["./server/server.ts"],
}),
tailwindcss(),
command === "serve" ? react() : undefined,
devServer({
entry: "./server/server.ts",
adapter: bunAdapter(),
}),
],
test: {
exclude: ["**/node_modules/**", "**/.direnv/**"],
server: {
deps: {
inline: ["zod"],
},
},
},
};
});