-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
62 lines (54 loc) · 1.62 KB
/
Copy pathvite.config.ts
File metadata and controls
62 lines (54 loc) · 1.62 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
import react from "@vitejs/plugin-react";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import { existsSync, readFileSync } from "node:fs";
import { parse } from "yaml";
const currentDir = path.dirname(fileURLToPath(import.meta.url));
export default () => {
const regelrettRoot = path.join(currentDir);
const defaultSettings = readFileSync(`${regelrettRoot}/conf/defaults.yaml`, {
encoding: "utf-8",
});
const customSettings = existsSync(`${regelrettRoot}/conf/custom.yaml`)
? readFileSync(`${regelrettRoot}/conf/custom.yaml`, {
encoding: "utf-8",
})
: "";
const defaults = parse(defaultSettings);
const custom = parse(customSettings);
const merged = {
...defaults.frontend_dev_server,
...custom?.frontend_dev_server,
};
const env: Record<string, unknown> = {};
for (const [key, value] of Object.entries(merged)) {
env[`RR_FRONTEND_DEV_SERVER_${key.toUpperCase()}`] = value;
}
for (const [key, _] of Object.entries(env)) {
const envVal = process.env[`${key}`];
if (envVal != undefined && envVal != "") {
env[key] = envVal;
}
}
return defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(currentDir, "./app"),
},
},
server: {
port: Number(env.RR_FRONTEND_DEV_SERVER_HTTP_PORT),
host: env.RR_FRONTEND_DEV_SERVER_HOST as string,
strictPort: true,
},
build: {
manifest: true,
rollupOptions: {
input: "./app/main.tsx",
},
},
});
};