forked from scalableminds/webknossos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
122 lines (118 loc) · 3.35 KB
/
vite.config.ts
File metadata and controls
122 lines (118 loc) · 3.35 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
121
122
import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";
import wasm from "vite-plugin-wasm";
import analyzer from "vite-bundle-analyzer";
import viteProtobufPlugin from "./frontend/vite/vite-plugin-protobuf";
import replaceSvgColorWithCurrentColor from "./frontend/vite/vite-plugin-replace-svg-color";
import path from "node:path";
import fs from "node:fs";
// This alias is mostly for resolves in LESS-files
// Code-related resolves are handled by "paths" in tsconfig.ts, tsconfigPaths-plugin respectively
const alias = {
"@images": path.resolve(__dirname, "frontend/assets/images"),
"@wasm": path.resolve(__dirname, "frontend/assets/wasm"),
};
// https://vite.dev/config/
export const viteConfig = {
// publicDir: "/assets",
resolve: { alias },
plugins: [
// analyzer(), // Enable/Disable vite bundle analyzer for inspecting the output bundle
react({
babel: {
plugins: ["babel-plugin-react-compiler"],
},
}),
svgr({
svgrOptions: {
icon: true,
jsx: {
babelConfig: {
plugins: [[replaceSvgColorWithCurrentColor, { patchStroke: true, patchFill: false }]],
},
},
},
}),
tsconfigPaths(),
wasm(),
viteProtobufPlugin({
protoDir: "webknossos-datastore/proto",
}),
],
optimizeDeps: {
exclude: ["three-mesh-bvh"],
},
build: {
copyPublicDir: true, // copy all /assets (images, etc.) to public/assets
outDir: "public", // note: /public is handled by the backend/Play framework for asset delivery
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules/html2canvas")) {
return "html2canvas";
}
},
},
},
},
worker: {
format: "es",
plugins: () => [wasm(), tsconfigPaths()],
},
server: {
port: 9000,
cors: true,
// https: {
// // Enable HTTPS with self-signed certificates for testing passkeys etc
// // Make sure you've generated SSL certificates using the ./tools/gen-ssl-dev-certs.sh script
// key: fs.readFileSync("./target/dev.key.pem"),
// cert: fs.readFileSync("./target/dev.cert.pem"),
// },
proxy: {
// Proxy to SAM service
"^/dist/": {
target: "http://localhost:8080",
changeOrigin: true,
},
// Proxy to Tracingstore / Datastore
"^/(api|data(?!set)|tracings)": {
target: "http://localhost:9001",
changeOrigin: true,
},
},
hmr: false, // disable Hot Module Replacement for now
watch: {
ignored: [
"**/node_modules/**",
"**/dist/**",
"**/frontend/javascripts/test/**",
"**/app/**",
"**/webknossos-tracingstore/**",
"**/webknossos-datastore/**",
"**/util/**",
"**/webknossos-jni/**",
"**/conf/**",
"**/project/**",
"**/docs/**",
"**/fossildb/**",
"**/target/**",
"**/schema/**",
"**/tools/**",
"**/binaryData/**",
"**/coverage/**",
"**/public/**",
"**/public-test/**",
"**/unreleased_changes/**",
"**/test/**",
],
},
},
define: {
global: "globalThis",
},
};
export default defineConfig(viteConfig);