harb/web-app/vite.config.ts

75 lines
2.5 KiB
TypeScript
Raw Normal View History

2025-07-24 16:08:17 +02:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import packageJson from './package.json' assert { type: 'json' }
2025-07-24 16:08:17 +02:00
// https://vite.dev/config/
2025-09-24 09:41:28 +02:00
export default defineConfig(() => {
const localRpcProxyTarget = process.env.VITE_LOCAL_RPC_PROXY_TARGET
2025-10-11 10:55:49 +00:00
const localGraphqlProxyTarget = process.env.VITE_LOCAL_GRAPHQL_PROXY_TARGET ?? 'http://127.0.0.1:42069'
const localTxnProxyTarget = process.env.VITE_LOCAL_TXN_PROXY_TARGET ?? 'http://127.0.0.1:43069'
const appVersion = (packageJson as { version?: string }).version ?? 'dev'
2025-09-24 09:41:28 +02:00
return {
2025-09-23 14:18:04 +02:00
// base: "/HarbergPublic/",
2025-09-24 09:41:28 +02:00
plugins: [
vue(),
vueDevTools(),
],
define: {
__APP_VERSION__: JSON.stringify(appVersion),
},
2025-09-24 09:41:28 +02:00
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'kraiken-lib': fileURLToPath(new URL('../kraiken-lib/src', import.meta.url)),
},
},
server: {
2025-10-11 10:55:49 +00:00
proxy:
localRpcProxyTarget || localGraphqlProxyTarget || localTxnProxyTarget
? {
...(localRpcProxyTarget
? {
'/api/rpc': {
target: localRpcProxyTarget,
changeOrigin: true,
secure: false,
rewrite: (path: string) => {
const rewritten = path.replace(/^\/api\/rpc/, '')
return rewritten.length === 0 ? '/' : rewritten
},
},
}
: {}),
...(localGraphqlProxyTarget
? {
'/api/graphql': {
target: localGraphqlProxyTarget,
changeOrigin: true,
secure: false,
rewrite: (path: string) => path.replace(/^\/api\/graphql/, '/graphql'),
},
}
: {}),
...(localTxnProxyTarget
? {
'/api/txn': {
target: localTxnProxyTarget,
changeOrigin: true,
secure: false,
rewrite: (path: string) => {
const rewritten = path.replace(/^\/api\/txn/, '')
return rewritten.length === 0 ? '/' : rewritten
},
},
}
: {}),
}
: undefined,
2025-07-24 16:08:17 +02:00
},
2025-09-24 09:41:28 +02:00
}
2025-07-24 16:08:17 +02:00
})