mirror of
https://github.com/UniversityOfHelsinkiCS/ohtuilmo.git
synced 2026-10-12 19:03:41 +03:00
40 lines
831 B
JavaScript
Executable File
40 lines
831 B
JavaScript
Executable File
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
|
|
const BACKEND_URL = `${env.VITE_BACKEND_URL || 'http://backend:3001'}`
|
|
const PORT = `${env.VITE_PORT || '3000'}`
|
|
|
|
if (command === 'serve') {
|
|
// when running dev server
|
|
return {
|
|
base: '/',
|
|
server: {
|
|
host: true,
|
|
port: PORT,
|
|
proxy: {
|
|
'/api': {
|
|
target: BACKEND_URL,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
plugins: [react()],
|
|
define: {
|
|
global: 'window',
|
|
},
|
|
}
|
|
} else {
|
|
// when building app
|
|
return {
|
|
base: '/projekti/',
|
|
plugins: [react()],
|
|
define: {
|
|
global: 'window',
|
|
},
|
|
}
|
|
}
|
|
})
|