-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
52 lines (45 loc) · 1.37 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
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig, splitVendorChunkPlugin, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import dns from 'dns';
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 base = process.env.PUBLIC_URL === '' ? '/' : process.env.PUBLIC_URL;
export default ({ mode }) => defineConfig({
base,
server: {
port: 3000,
host: 'localhost',
open: true,
proxy: setProxy({ mode }),
},
plugins: [splitVendorChunkPlugin(), react()],
define: {
'process.env.NODE_ENV': `"${mode}"`,
},
build: {
outDir: 'build',
commonjsOptions: {
transformMixedEsModules: true,
},
},
});