forked from z1g-project/Ephemeral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
77 lines (76 loc) · 1.92 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
import { execSync } from 'node:child_process';
import type { Socket } from 'node:net';
import path from 'node:path';
import { baremuxPath } from '@mercuryworkshop/bare-mux/node';
import { epoxyPath } from '@mercuryworkshop/epoxy-transport';
import { libcurlPath } from '@mercuryworkshop/libcurl-transport';
import { server as wisp } from '@mercuryworkshop/wisp-js/server';
import { uvPath } from '@titaniumnetwork-dev/ultraviolet';
import react from '@vitejs/plugin-react-swc';
import { meteorPath } from 'meteorproxy';
import million from 'million/compiler';
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
// https://vitejs.dev/config/
export default defineConfig({
build: {
target: 'ES2022',
chunkSizeWarningLimit: 2700,
},
plugins: [
{
name: 'vite-wisp-server',
configureServer(server) {
server.httpServer?.on('upgrade', (req, socket: Socket, head) =>
req.url?.startsWith('/wisp')
? wisp.routeRequest(req, socket, head)
: undefined,
);
},
},
viteStaticCopy({
targets: [
{
src: `${uvPath}/uv.*`.replace(/\\/g, '/'),
dest: 'uv',
overwrite: false,
},
{
src: `${meteorPath}/meteor.*`.replace(/\\/g, '/'),
dest: 'meteor',
overwrite: false,
},
{
src: `${libcurlPath}/**/*`.replace(/\\/g, '/'),
dest: 'libcurl',
overwrite: false,
},
{
src: `${epoxyPath}/**/*`.replace(/\\/g, '/'),
dest: 'epoxy',
overwrite: false,
},
{
src: `${baremuxPath}/**/*`.replace(/\\/g, '/'),
dest: 'baremux',
overwrite: false,
},
],
}),
million.vite({ auto: true }),
react(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
define: {
__BUILD_DATE__: Date.now(),
__GIT_COMMIT__: JSON.stringify(
process.env.VERCEL_GIT_COMMIT_SHA ??
process.env.CF_PAGES_COMMIT_SHA ??
execSync('git rev-parse HEAD').toString().trim(),
),
},
});