-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
50 lines (48 loc) · 1.27 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
import react from "@vitejs/plugin-react-swc"
import { fileURLToPath, URL } from "node:url"
import { visualizer } from "rollup-plugin-visualizer"
import AutoImport from "unplugin-auto-import/vite"
import { TanStackRouterVite } from "@tanstack/router-vite-plugin"
import { defineConfig } from "vite"
import path from "node:path"
const cdn = {
react: "https://esm.sh/react@18.2.0",
"react-dom": "https://esm.sh/react-dom@18.2.0",
}
export default defineConfig(({ mode }) => ({
build: {
emptyOutDir: true,
outDir: "dist",
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) return "vendor"
},
},
},
},
plugins: [
react({
jsxImportSource: "@emotion/react",
}),
TanStackRouterVite({
routesDirectory: "./src/pages",
generatedRouteTree: "./src/routes.gen.ts",
}),
AutoImport({
imports: ["react"],
dirs: ["./src/components", "./src/hooks"],
dts: "./src/types/auto-imports.d.ts",
}),
mode === "analyze" &&
visualizer({
filename: path.join(__dirname, "dist/stats.html"),
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
...(mode === "development" ? {} : cdn),
},
},
}))