-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvite.config.ts
More file actions
98 lines (96 loc) · 3.12 KB
/
vite.config.ts
File metadata and controls
98 lines (96 loc) · 3.12 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import path from "path";
import { visualizer } from "rollup-plugin-visualizer";
import analyzer from "rollup-plugin-analyzer";
import removeConsole from "./vite-plugin-remove-console.js";
import pkg from "./package.json";
export default defineConfig(() => {
const projectRoot = __dirname;
const rendererRoot = path.resolve(projectRoot, "src/renderer");
const windowsRoot = path.resolve(rendererRoot, "windows");
const isAnalyze = process.env.ANALYZE === "true";
return {
// Vite 개발 서버 루트: /main/index.html, /overlay/index.html 경로로 접근 가능
root: windowsRoot,
base: "./",
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
plugins: [
react({
babel: {
plugins: [
["babel-plugin-react-compiler", {
// signals 파일 제외
sources: (filename: string) => {
if (filename.includes('stores/signals/')) return false;
return true;
},
}],
],
},
}),
svgr({
include: "**/*.svg",
svgrOptions: {
// named export: { ReactComponent }
exportType: "default",
},
}),
removeConsole(),
isAnalyze &&
analyzer({
summaryOnly: true,
}),
isAnalyze &&
visualizer({
filename: path.resolve(projectRoot, "dist", "stats.html"),
template: "treemap",
gzipSize: true,
brotliSize: true,
open: false,
}),
].filter(Boolean),
server: {
port: 3400,
strictPort: true,
open: false,
fs: {
// 루트 상위(src/renderer 등) 경로 import 허용
allow: [projectRoot, rendererRoot, windowsRoot],
},
},
resolve: {
alias: {
"@components": path.resolve(rendererRoot, "components"),
"@styles": path.resolve(rendererRoot, "styles"),
"@windows": path.resolve(rendererRoot, "windows"),
"@hooks": path.resolve(rendererRoot, "hooks"),
"@api": path.resolve(rendererRoot, "api"),
"@assets": path.resolve(rendererRoot, "assets"),
"@utils": path.resolve(rendererRoot, "utils"),
"@stores": path.resolve(rendererRoot, "stores"),
"@constants": path.resolve(rendererRoot, "constants"),
"@contexts": path.resolve(rendererRoot, "contexts"),
"@plugins": path.resolve(rendererRoot, "plugins"),
"@config": path.resolve(rendererRoot, "config"),
"@shared": path.resolve(projectRoot, "src/types"),
"@src": path.resolve(projectRoot, "src/"),
},
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
},
build: {
outDir: path.resolve(projectRoot, "dist/renderer"),
emptyOutDir: true,
rollupOptions: {
input: {
main: path.resolve(windowsRoot, "main/index.html"),
overlay: path.resolve(windowsRoot, "overlay/index.html"),
obs: path.resolve(windowsRoot, "obs/index.html"),
},
},
},
};
});