-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
120 lines (114 loc) · 3.33 KB
/
Copy pathvite.config.ts
File metadata and controls
120 lines (114 loc) · 3.33 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import path from "node:path";
import { fileURLToPath } from "node:url";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { codaroLayerOrderPlugin } from "../assets/brand/tools/viteLayerOrder.mjs";
const dirname = path.dirname(fileURLToPath(import.meta.url));
const apiProxyTarget = process.env.CODARO_DEV_API_PROXY?.replace(/\/$/, "");
const codeSplitting = {
groups: [
{
name: "vitePreload",
test: /\0vite[\/]preload-helper\.js$/,
priority: 100,
},
{
name: "markdownRuntime",
test: /[\\/]node_modules[\\/](?:dompurify|marked)[\\/]/,
priority: 80,
},
{
name: "diagramRuntime",
test: /[\\/]node_modules[\\/](?:@antfu|@braintree|@chevrotain|@iconify|@mermaid-js|@upsetjs|commander|cose-base|cytoscape(?:-cose-bilkent|-fcose)?|d3(?:-[^\\/]+)?|dagre-d3-es|dayjs|delaunator|es-toolkit|hachure-fill|iconv-lite|import-meta-resolve|internmap|katex|khroma|layout-base|lodash-es|mermaid|package-manager-detector|path-data-parser|points-on-curve|points-on-path|robust-predicates|roughjs|rw|safer-buffer|stylis|tinyexec|ts-dedent|uuid)[\\/]/,
priority: 70,
},
{
name: "yaml",
test: /[\\/]node_modules[\\/].*[\\/]yaml[\\/]|[\\/]src[\\/]lib[\\/]curriculaRegistry\.ts$/,
priority: 60,
},
{
name: "curriculumMarkdown",
test: /[\\/]components[\\/]curriculum[\\/]curriculumMarkdown[^\\/]*\.tsx?$/,
priority: 55,
},
{
name: "curriculumSurface",
test: /[\\/]components[\\/]curriculum[\\/]curriculumSurface\.tsx$/,
priority: 50,
},
{
name: "codemirror",
test: /@codemirror|@lezer/,
priority: 40,
},
{
name: "radix",
test: /@radix-ui/,
priority: 40,
},
{
name: "icons",
test: /lucide-react/,
priority: 40,
},
{
name: "xterm",
test: /@xterm/,
priority: 40,
},
{
name: "vendor",
test: /[\\/]node_modules[\\/]/,
priority: 10,
},
],
};
// 웹(Pages) 서빙용 빌드 변형: 같은 에디터를 /codaro/run/과 호환 /codaro/app/에 올릴 때 env로 덮는다.
// 로컬 제품 빌드(webBuild)는 기본값 그대로라 영향이 없다.
// base 값은 슬래시 없이 받는다(예: "codaro/run") - Git Bash(MSYS)가 선행 "/"를 윈도 경로로
// 변환해 망가뜨리므로 여기서 정규화한다.
const webBase = process.env.CODARO_WEB_BASE;
const webOutDir = process.env.CODARO_WEB_OUT;
export default defineConfig({
base: webBase ? `/${webBase.replace(/^\/+|\/+$/g, "")}/` : "/",
plugins: [
codaroLayerOrderPlugin(),
react(),
tailwindcss(),
],
server: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "credentialless",
},
fs: {
allow: [dirname, path.resolve(dirname, "..")],
},
proxy: apiProxyTarget
? {
"/api": {
changeOrigin: true,
target: apiProxyTarget,
},
}
: undefined,
},
build: {
assetsDir: "_app",
emptyOutDir: true,
modulePreload: false,
outDir: webOutDir || "../src/codaro/webBuild",
rolldownOptions: {
output: {
codeSplitting,
},
},
},
resolve: {
alias: {
"@": path.resolve(dirname, "./src"),
},
},
});