nextjs-fastapi/vite.config.ts

34 lines
782 B
TypeScript

import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};
return defineConfig({
server: {
host: process.env.VITE_HOST,
proxy: {
'/api': {
target: process.env.VITE_API_URL,
changeOrigin: true,
rewrite: (path) => {
return path.replace(/^\/api/, '');
},
}
}
},
plugins: [
vue(),
vueJsx(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./app', import.meta.url))
}
}
});
}