-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
61 lines (59 loc) · 1.9 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
import react from "@vitejs/plugin-react-swc"
import fs from "fs"
import path from "path"
import { defineConfig, Plugin } from "vite"
const loadSettingFiles = (): Plugin => {
return {
name: "load-setting-files-plugin",
config(config) {
config.define = config.define || {};
[
"SIO_SERV_UI_TABLE_FILE",
"SIO_SERV_WF_PARAMS_SCHEMA_FILE",
"SIO_SERV_RUN_REQUEST_FILE",
].forEach((key) => {
const file = process.env[key]
if (file === undefined) {
throw new Error(`The environment variable ${key} is not set.`)
}
if (fs.existsSync(file) === false) {
throw new Error(`The file ${file} does not exist.`)
}
const fileContent = fs.readFileSync(file, "utf-8")
const defineKey = `${key.replace("SIO_SERV_", "")}_CONTENT`
config.define![defineKey] = JSON.stringify(fileContent)
})
},
}
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
loadSettingFiles(),
],
root: "./src",
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
build: {
outDir: "../dist",
},
server: {
host: process.env.SIO_SERV_HOST || "0.0.0.0",
port: parseInt(process.env.SIO_SERV_PORT || "3000"),
},
preview: {
host: process.env.SIO_SERV_HOST || "0.0.0.0",
port: parseInt(process.env.SIO_SERV_PORT || "3000"),
},
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
KEYCLOAK_REALM_URL: JSON.stringify(process.env.SIO_SERV_KEYCLOAK_REALM_URL || "http://localhost:8080/auth/realms/sio-serv"),
KEYCLOAK_CLIENT_ID: JSON.stringify(process.env.SIO_SERV_KEYCLOAK_CLIENT_ID || "sio-serv-spa"),
MINIO_ENDPOINT: JSON.stringify(process.env.SIO_SERV_MINIO_ENDPOINT || "http://localhost:9000"),
SAPPORO_ENDPOINT: JSON.stringify(process.env.SIO_SERV_SAPPORO_ENDPOINT || "http://localhost:1122"),
},
})