-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathvite-player.mjs
executable file
·52 lines (46 loc) · 1.2 KB
/
vite-player.mjs
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
#!/usr/bin/env node
import reactPlugin from '@vitejs/plugin-react'
import chalk from 'chalk'
import { createServer } from 'vite'
const defaultCamera = 'http://192.168.0.90'
let host = process.env.MSP_CAMERA
if (!host) {
console.warn(
chalk.red`
WARNING: no MSP_CAMERA environment variable detected, will use default.
If you want to use a specific camera, please pass its host to the
environment variable CAMERA, like so:
export MSP_CAMERA=http://camera-ip:port
`
)
host = defaultCamera
}
const unicornDivider = () =>
console.log(
'🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄'
)
await createServer({
root: './src/player',
dedupe: ['react', 'react-dom'],
configFile: false,
sourcemap: 'inline',
server: {
proxy: {
'^/(axis-cgi|vapix|local|rtsp-over-websocket).*': {
target: host,
ws: true,
changeOrigin: true,
},
},
},
plugins: [reactPlugin()],
})
.then((server) => {
return server.listen()
})
.then((server) => {
unicornDivider()
server.printUrls()
console.log(`VAPIX requests will be forwarded to: ${host}`)
unicornDivider()
})