forked from aziontech/azion-console-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
54 lines (50 loc) · 1.99 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
import process from 'process'
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
const getConfig = () => {
const env = loadEnv('development', process.cwd())
const URLStartPrefix = env.VITE_ENVIRONMENT === 'PRODUCTION' ? 'https://' : 'https://stage-'
return {
plugins: [vue(), vueJsx()],
resolve: {
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json', '.vue'],
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@templates': fileURLToPath(new URL('./src/templates', import.meta.url)),
'@views': fileURLToPath(new URL('./src/views', import.meta.url)),
'@services': fileURLToPath(new URL('./src/services', import.meta.url)),
'@stores': fileURLToPath(new URL('./src/stores', import.meta.url)),
'@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
'@routes': fileURLToPath(new URL('./src/router/routes', import.meta.url))
}
},
server: {
proxy: {
'^/api/(marketplace|script-runner|template-engine)': {
target: `${URLStartPrefix}manager.azion.com/`,
changeOrigin: true,
rewrite: (path) =>
path.replace(/^\/api\/(marketplace|script-runner|template-engine)/, '/$1/api')
},
'/graphql/cities': {
target: `${URLStartPrefix}cities.azion.com`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/graphql\/cities/, '/graphql')
},
'^/api/(account|user|token|switch-account|password|totp)|^/logout': {
target: `${URLStartPrefix}sso.azion.com`,
changeOrigin: true,
cookieDomainRewrite: { '*': '' }
},
'/api': {
target: `${URLStartPrefix}api.azion.com`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
}
}
export default defineConfig(getConfig())