-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
42 lines (39 loc) · 1.05 KB
/
vite.config.js
File metadata and controls
42 lines (39 loc) · 1.05 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
import { resolve } from "node:path";
import { readFileSync } from "node:fs";
import { defineConfig, loadEnv, } from "vite";
import react from "@vitejs/plugin-react";
import svgr from '@svgr/rollup'
const arr = (str) => str ? str.split(',') : []
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
console.log('defineConfig mode:', mode)
const {
HOST, PORT, HTTPS, SSL_CRT_FILE, SSL_KEY_FILE, ALLOWED_HOSTS
} = loadEnv(mode, ".", [
"HOST", "PORT", "HTTPS", "SSL_CRT_FILE", "SSL_KEY_FILE", "ALLOWED_HOSTS"
]);
const https = HTTPS === "true";
const port = parseInt(PORT || "3690", 10)
return {
base: '/',
plugins: [
react(),
svgr(),
],
build: {
sourcemap: true,
},
server: {
host: HOST || "0.0.0.0",
port,
open: false,
...(https && SSL_CRT_FILE && SSL_KEY_FILE && {
https: {
cert: readFileSync(resolve(SSL_CRT_FILE)),
key: readFileSync(resolve(SSL_KEY_FILE)),
},
}),
allowedHosts: arr(ALLOWED_HOSTS),
},
}
});