-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
132 lines (131 loc) · 4.04 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
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
121
122
123
124
125
126
127
128
129
130
131
132
import {defineConfig, loadEnv} from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import svgr from "vite-plugin-svgr";
import glsl from "vite-plugin-glsl";
// https://vitejs.dev/config/
//@ts-ignore
export default defineConfig(() => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
// eslint-disable-next-line no-undef
const env = loadEnv("development", process.cwd(), "");
return {
// vite config
plugins: [
react(),
glsl({
include: [
// Glob pattern, or array of glob patterns to import
"**/*.glsl",
"**/*.wgsl",
"**/*.vert",
"**/*.frag",
"**/*.vs",
"**/*.fs",
],
exclude: undefined, // Glob pattern, or array of glob patterns to ignore
warnDuplicatedImports: true, // Warn if the same chunk was imported multiple times
defaultExtension: "glsl", // Shader suffix when no extension is specified
compress: false, // Compress output shader code
watch: true, // Recompile shader on change
root: "/", // Directory for root imports
}),
svgr({
svgrOptions: {
exportType: "named",
ref: true,
svgo: false,
titleProp: true,
},
include: "**/*.svg",
}),
],
worker: {
plugins: [react()],
},
server: {
port: env.PORT, // set port
},
esbuild: {
jsxFactory: "React.createElement",
jsxFragment: "React.Fragment",
},
resolve: {
alias: {
"@assets": path.resolve(__dirname, "./src/assets"),
"@BimModel": path.resolve(__dirname, "./src/BimModel"),
"@CubeMapComponent": path.resolve(
__dirname,
"./src/BimModel/src/CubeMapComponent"
),
"@MaterialComponent": path.resolve(
__dirname,
"./src/BimModel/src/MaterialComponent"
),
"@ModelingComponent": path.resolve(
__dirname,
"./src/BimModel/src/ModelingComponent"
),
"@PropertyComponent": path.resolve(
__dirname,
"./src/BimModel/src/PropertyComponent"
),
"@RendererComponent": path.resolve(
__dirname,
"./src/BimModel/src/RendererComponent"
),
"@ProjectComponent": path.resolve(
__dirname,
"./src/BimModel/src/ProjectComponent"
),
"@LevelSystem": path.resolve(
__dirname,
"./src/BimModel/src/LevelSystem"
),
"@GridSystem": path.resolve(__dirname, "./src/BimModel/src/GridSystem"),
"@WorkPlane": path.resolve(__dirname, "./src/BimModel/src/WorkPlane"),
"@DrawTool": path.resolve(__dirname, "./src/BimModel/src/DrawTool"),
"@system": path.resolve(__dirname, "./src/BimModel/src/system"),
"@components": path.resolve(__dirname, "./src/components"),
"@signals": path.resolve(__dirname, "./src/signals"),
"@pages": path.resolve(__dirname, "./src/pages"),
"@baseTypes": path.resolve(__dirname, "./src/baseTypes"),
"@": path.resolve(__dirname, "./src"),
},
},
base: "./",
build: {
outDir: "./build",
chunkSizeWarningLimit: false,
rollupOptions: {
output: {
manualChunks(id: string) {
// creating a chunk to @open-ish deps. Reducing the vendor chunk size
if (id.includes("clay")) {
return "clay.min";
}
if (id.includes("three")) {
return "three.min";
}
if (id.includes("web-ifc")) {
return "web-ifc.min";
}
},
},
},
},
test: {
global: true,
environment: "jsdom",
},
optimizeDeps: {
exclude: [
"js-big-decimal",
"three-mesh-bvh",
"three-mesh-bvh/src/workers/GenerateMeshBVHWorker.js",
"three-mesh-bvh/src/workers/ParallelMeshBVHWorker.js",
],
},
};
});