-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
56 lines (49 loc) · 1.49 KB
/
vite.config.js
File metadata and controls
56 lines (49 loc) · 1.49 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable import/no-extraneous-dependencies */
import dns from 'dns';
import react from '@vitejs/plugin-react';
import { defineConfig, splitVendorChunkPlugin, loadEnv } from 'vite';
dns.setDefaultResultOrder('verbatim');
const setProxy = ({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const VIDISPINE_ENDPOINTS = ['/API/', '/APInoauth/', '/APIinit/', '/APIdoc/', '/UploadLicense/'];
const VIDISPINE_URL = env.VITE_VIDISPINE_URL === '' ? undefined : env.VITE_VIDISPINE_URL;
const proxyOptions = {
target: VIDISPINE_URL,
changeOrigin: true,
selfHandleResponse: false,
configure: (proxy) => {
proxy.on('proxyRes', (proxyRes) => {
// eslint-disable-next-line no-param-reassign
delete proxyRes.headers['www-authenticate'];
});
},
};
const proxy = VIDISPINE_URL
? VIDISPINE_ENDPOINTS.reduce((a, c) => ({ ...a, [c]: proxyOptions }), {})
: undefined;
return proxy;
};
const setBase = ({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const base = env.BASE_URL === '' ? '/' : env.BASE_URL;
return base;
};
export default ({ mode }) =>
defineConfig({
base: setBase({ mode }),
server: {
port: 3000,
host: 'localhost',
proxy: setProxy({ mode }),
},
plugins: [splitVendorChunkPlugin(), react()],
define: {
'process.env.NODE_ENV': `"${mode}"`,
},
build: {
outDir: 'build',
commonjsOptions: {
transformMixedEsModules: true,
},
},
});