33 lines
962 B
TypeScript
33 lines
962 B
TypeScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
const apiTarget = env.VITE_API_URL || 'https://testapp.digitaltelecom.net';
|
|
|
|
return {
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: env.VITE_API_URL
|
|
? undefined
|
|
: {
|
|
'/api': { target: apiTarget, changeOrigin: true, secure: true },
|
|
'/auth': { target: apiTarget, changeOrigin: true, secure: true },
|
|
'/contador': { target: apiTarget, changeOrigin: true, secure: true },
|
|
'/ws': {
|
|
target: apiTarget.replace(/^http/i, 'ws'),
|
|
ws: true,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|