This repository was archived by the owner on Aug 12, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
67 lines (61 loc) · 1.79 KB
/
vite.config.ts
File metadata and controls
67 lines (61 loc) · 1.79 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
import { resolve } from 'path';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import react from '@vitejs/plugin-react';
export default defineConfig((_) => {
if (!process.env.SERVER) {
throw Error('SERVER Environment Variable was not provided.');
}
let server;
switch (process.env.SERVER) {
case 'prod':
server = 'https://jd.tandashi.de';
break;
case 'dev':
server = 'https://jd-dev.tandashi.de';
break;
case 'local':
default:
server = 'http://localhost:3000';
break;
}
if (!server) {
throw Error('No valid value for SERVER was defined. (local, dev, prod)');
}
return {
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
LOGGING_ENABLED: process.env.logging ? 'true' : 'false',
EBS_SERVER_URL: server,
},
build: {
rollupOptions: {
input: [
resolve(__dirname, 'twitch-public/panel.html'),
resolve(__dirname, 'twitch-public/mobile.html'),
resolve(__dirname, 'twitch-public/video-component.html'),
resolve(__dirname, 'twitch-public/live-configuration.html'),
resolve(__dirname, 'twitch-public/configuration.html'),
],
},
},
plugins: [
react(),
tsconfigPaths(),
{
name: 'remove-src-dir-from-html-path',
enforce: 'post',
generateBundle(_, bundle) {
const htmlFileInSrcFolderPattern = /^twitch-public\/.*\.html$/;
for (const outputItem of Object.values(bundle)) {
if (!htmlFileInSrcFolderPattern.test(outputItem.fileName)) {
continue;
}
outputItem.fileName = outputItem.fileName.replace('twitch-public/', '');
}
},
},
],
clean: true,
};
});