Files
rmcampos a96a113f49
Frontend CD / build (push) Failing after 2m31s
chore: fix ngrok setup to run locally
2026-08-07 15:55:04 +02:00

68 lines
1.5 KiB
TypeScript

import { ConfigEnv, defineConfig, UserConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath } from 'url';
import path from 'path';
const proxyConfig = process.env.NGROK
? {
'/api': {
target: `http://${process.env.BACKEND_HOST || 'localhost'}:8585`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
}
: undefined;
export default defineConfig(({ mode }: ConfigEnv) => {
const config: UserConfig = {
define: {},
plugins: [
{
name: 'build-html',
apply: 'build',
transformIndexHtml: (html) => {
return {
html,
tags: [
{
tag: 'script',
attrs: {
src: '/env.js'
},
injectTo: 'head'
}
]
};
}
},
react()
],
build: {
outDir: 'dist',
sourcemap: mode === 'development'
},
server: {
port: 5000,
...(process.env.NGROK ? { allowedHosts: ['.ngrok-free.dev'] } : {}),
proxy: proxyConfig,
},
preview: {
port: 5000
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap')
}
}
};
if (mode === 'development') {
if (config.define) {
config.define.global = {};
}
}
return config;
});