-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
73 lines (69 loc) · 1.83 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import path, { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
const appSrc = path.resolve(__dirname, 'frontend/src')
const resolvePath = relPath => path.join(appSrc, relPath)
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, './env') || {}
const env_repl = {}
for (const key in env) {
env_repl[key] = `"${env[key]}"`
}
return ({
plugins: [react()],
root: 'frontend',
public: path.resolve(__dirname, 'frontend/public'),
base: mode === 'staging' ? '/ilwol-booking/' : undefined,
define: {
'$TEST': '"test-string"',
...env_repl
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
loadPaths: [ resolvePath('styles') ],
additionalData: '@use "global_scss_utils" as *;'
}
}
},
resolve: {
alias: {
'~': appSrc,
'@components': resolvePath('components'),
'@pages': resolvePath('pages'),
'@utils': resolvePath('utilities.jsx'),
'@view-data': resolvePath('view-data'),
'@styles': resolvePath('styles'),
'@store': resolvePath('store'),
'@hooks': resolvePath('hooks')
}
},
build: {
outDir: path.resolve(__dirname, './dist'),
rollupOptions: {
output: {
manualChunks: {
'third-parties': [
'react',
'react-dom',
'react-redux',
'react-router-dom',
'react-calendar',
'@reduxjs/toolkit',
'use-immer',
'dayjs'
]
}
}
}
},
server: {
// dev-server configuration
proxy: {
'/api': `http://127.0.0.1:${env.VITE_DEV_API_PORT}`
}
}
})
})