-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvite.config.ts
75 lines (71 loc) · 2.14 KB
/
vite.config.ts
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
70
71
72
73
74
75
import react from "@vitejs/plugin-react";
import reactSWC from "@vitejs/plugin-react-swc";
import path from "node:path";
import tailwindcss from "tailwindcss";
import { defineConfig, PluginOption } from "vite";
import tsConfigPaths from "vite-tsconfig-paths";
export default defineConfig(({ command }) => {
const isDev = command === "serve";
process.env.NODE_ENV = isDev ? "development" : "production";
return {
root: "./src/renderer",
appType: "mpa",
base: "",
publicDir: path.resolve(import.meta.dirname, "public"),
build: {
outDir: path.resolve(import.meta.dirname, "build", isDev ? "dev" : "prod", "renderer"),
emptyOutDir: true,
chunkSizeWarningLimit: 1024,
rollupOptions: {
output: {
manualChunks: isDev ? undefined : {
heroui: ["@heroui/react"],
theme: ["@heroui/theme"],
lucide: ["lucide-react"]
}
}
}
},
plugins: [
isDev ?
reactSWC() :
// Use React Compiler in production for better performance
react({
babel: {
plugins: [
["babel-plugin-react-compiler", { target: "19" }]
]
}
}),
tsConfigPaths(),
i18nHotReload()
],
define: {},
css: {
postcss: {
plugins: [tailwindcss()]
}
},
server: {
warmup: {
clientFiles: ["index.html"]
}
},
esbuild: {
legalComments: "none"
}
};
});
function i18nHotReload(): PluginOption {
return {
name: "i18n-hot-reload",
handleHotUpdate({ file, server }) {
if (file.includes("i18n") && file.endsWith(".yml")) {
server.ws.send({
type: "custom",
event: "locales-update"
});
}
}
};
}