-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
63 lines (52 loc) · 1.21 KB
/
vite.config.js
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
import { fileURLToPath, URL } from 'url'
import { defineConfig, loadEnv } from 'vite'
import { resolve } from 'path'
import { readFileSync } from 'fs'
import vue from '@vitejs/plugin-vue'
// Exports Vite config.
export default ({ mode }) => {
// Loads env variables.
const env = loadEnv(mode, process.cwd(), '')
// Configures http dev server.
let devServer = {
host: '0.0.0.0',
port: 8080,
https: false,
proxy: {
'/socket.io': {
target: 'ws://0.0.0.0:8080',
ws: true
}
}
}
// Configures https dev server.
// @todo This is not working.
if (process.argv.includes("--https")) {
const ssl_key = resolve(`${env.LOCAL_KEY}`)
const ssl_cert = resolve(`${env.LOCAL_CERT}`)
devServer = {
host: '0.0.0.0',
port: 443,
https: {
key: readFileSync(ssl_key),
cert: readFileSync(ssl_cert)
},
proxy: {
'/socket.io': {
target: `ws://${env.LOCAL_URL}`,
ws: true
}
}
}
}
// Returns config.
return defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: devServer
})
}