51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { ConfigEnv, defineConfig, loadEnv, type UserConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig((result: ConfigEnv) => {
|
|
const { command, mode } = result
|
|
const env = loadEnv(mode, process.cwd())
|
|
|
|
if (command === 'serve') {
|
|
// dev specific config
|
|
console.log(
|
|
'loading environment variables from .env and .env.' + mode + ' under ' + process.cwd()
|
|
)
|
|
}
|
|
|
|
console.log('backend api url: ' + (env.VITE_PROXY_API_URL || 'http://localhost:8888'))
|
|
|
|
return {
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
vueDevTools(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
},
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5173,
|
|
proxy: {
|
|
'^/api/': {
|
|
target: env.VITE_PROXY_API_URL || 'http://localhost:8888',
|
|
changeOrigin: true,
|
|
secure: true,
|
|
ws: true,
|
|
rewrite: (path) => {
|
|
console.info(path)
|
|
return path
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} as UserConfig
|
|
})
|