-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.charts.ts
59 lines (56 loc) · 1.62 KB
/
vite.config.charts.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
import { defineConfig } from "vite";
const env = {
GALAXY_DATASET_ID: "",
GALAXY_HISTORY_ID: "",
GALAXY_KEY: "",
GALAXY_ROOT: "http://127.0.0.1:8080",
};
// add history id for testing
Object.keys(env).forEach((key) => {
if (process.env[key]) {
env[key] = process.env[key];
} else {
console.log(`${key} not available. Please provide as environment variable.`);
}
});
// https://vitejs.dev/config/
export const viteConfigCharts = defineConfig({
build: {
outDir: "./static/dist",
emptyOutDir: true,
rollupOptions: {
output: {
manualChunks: () => "app.js",
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
assetFileNames: "[name][extname]",
},
},
},
define: {
"process.env.credentials": JSON.stringify(env.GALAXY_KEY ? "omit" : "include"),
"process.env.dataset_id": JSON.stringify(env.GALAXY_DATASET_ID),
"process.env.history_id": JSON.stringify(env.GALAXY_HISTORY_ID),
},
resolve: {
alias: {
"@": "/src",
},
},
server: {
proxy: {
"/api": {
changeOrigin: true,
rewrite: (path) => {
if (env.GALAXY_KEY) {
const separator = path.includes("?") ? "&" : "?";
return `${path}${separator}key=${env.GALAXY_KEY}`;
} else {
return path;
}
},
target: env.GALAXY_ROOT,
},
},
},
});