-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathvite.config.js
More file actions
54 lines (53 loc) · 1.31 KB
/
vite.config.js
File metadata and controls
54 lines (53 loc) · 1.31 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
import { defineConfig, loadEnv } from 'vite';
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
base: '/',
resolve: {
alias: {
'~': resolve('src/'),
},
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:4500',
changeOrigin: true,
secure: false,
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
define: {
...Object.keys(env).reduce((prev, key) => {
const sanitizedKey = key.replace(/[^a-zA-Z0-9_]/g, '_');
// eslint-disable-next-line no-param-reassign
prev[`process.env.${sanitizedKey}`] = JSON.stringify(env[key]);
return prev;
}, {}),
},
build: {
outDir: 'build',
},
plugins: [
react({
babel: {
plugins: ['@babel/plugin-transform-logical-assignment-operators'],
},
}),
],
optimizeDeps: {
include: [
'react-popper',
'react-datepicker',
'react-tooltip',
'react-bootstrap',
'libphonenumber-js/max',
],
force: true, // force re-bundle after cache issues; set to false once deps load
},
};
});