-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
73 lines (67 loc) · 2.02 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
import react from '@vitejs/plugin-react-swc';
import dotenv from 'dotenv';
import path from 'path';
import {defineConfig} from 'vite';
import {ViteEjsPlugin} from 'vite-plugin-ejs';
dotenv.config();
// import dns from 'dns';
// Due to https://stackoverflow.com/a/75191787
// dns.setDefaultResultOrder('verbatim');
const production = process.env.NODE_ENV === 'production';
const SHOW_ENVIRONMENT_DISCLAIMER = process.env.SHOW_ENVIRONMENT_DISCLAIMER || 'false';
const STOCK_SERVICE_HOST = process.env.STOCK_SERVICE_HOST || 'http://localhost:7080';
const MAIL_SERVICE_HOST = process.env.MAIL_SERVICE_HOST;
const POCKETBASE_URL = process.env.POCKETBASE_URL || '';
// https://vitejs.dev/config/
export default defineConfig({
// https://github.com/vitejs/vite/issues/1973#issuecomment-787571499
define: {
'process.env': {
SHOW_ENVIRONMENT_DISCLAIMER: SHOW_ENVIRONMENT_DISCLAIMER,
STOCK_SERVICE_HOST: STOCK_SERVICE_HOST,
MAIL_SERVICE_HOST: MAIL_SERVICE_HOST,
POCKETBASE_URL: POCKETBASE_URL,
NODE_ENV: process.env.NODE_ENV,
},
},
server: {
open: true,
host: 'localhost',
port: 3000,
proxy: !production
? {
'/stock_service': {
target: STOCK_SERVICE_HOST,
changeOrigin: true,
rewrite: path => path.replace('/stock_service', ''),
},
'/mail_service': {
target: MAIL_SERVICE_HOST,
changeOrigin: true,
rewrite: path => path.replace('/mail_service', ''),
},
// "/socket": {
// target: "http://localhost:7070",
// changeOrigin: true,
// ws: true,
// rewrite: (path) => path.replace("/socket", ""),
// },
}
: undefined,
},
resolve: {
alias: [{find: '@', replacement: path.resolve(__dirname, 'src')}],
},
build: {
outDir: 'build',
},
plugins: [
react(),
ViteEjsPlugin(config => {
return {
...config,
isProd: config.mode === 'production',
};
}),
],
});