-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.ts
More file actions
105 lines (98 loc) · 2.62 KB
/
vite.config.ts
File metadata and controls
105 lines (98 loc) · 2.62 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import path from "node:path";
import babel from "@rolldown/plugin-babel";
import tailwindcss from "@tailwindcss/vite";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig, type PluginOption } from "vite";
const platform = process.env.TAURI_ENV_PLATFORM;
console.debug("platform : ", platform);
const target = (() => {
if (platform === "windows") return "chrome139";
if (platform === "darwin") return "safari16";
return "es2020";
})();
const reactDevTools = (): PluginOption => {
return {
name: "react-devtools",
apply: "serve",
transformIndexHtml(html) {
return {
html,
tags: [
{
tag: "script",
attrs: {
src: "http://localhost:8097",
},
injectTo: "head",
},
],
};
},
};
};
// https://vitejs.dev/config/
export default defineConfig(async ({ mode }) => ({
plugins: [
react(),
babel({ presets: [reactCompilerPreset()] }),
tailwindcss(),
reactDevTools(),
],
build: {
target: target,
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{
name: "vendor-react",
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
},
{
name: "vendor-i18n",
test: /[\\/]node_modules[\\/](i18next|react-i18next)[\\/]/,
},
{ name: "vendor-state", test: /[\\/]node_modules[\\/]jotai[\\/]/ },
{ name: "vendor-dnd", test: /[\\/]node_modules[\\/]@dnd-kit[\\/]/ },
{
name: "vendor-radix",
test: /[\\/]node_modules[\\/]@radix-ui[\\/]/,
},
{
name: "vendor-tauri",
test: /[\\/]node_modules[\\/]@tauri-apps[\\/]/,
},
],
},
},
plugins: [
// Enable `npx vite build --mode analyze`
mode === "analyze" &&
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
}),
],
},
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1520,
strictPort: true,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
}));