import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

const rootDir = fileURLToPath(new URL('.', import.meta.url));
const frontendDir = path.resolve(rootDir, '../apps/frontend');

export default defineConfig({
  plugins: [react(), tailwindcss()],
  clearScreen: false,
  server: {
    port: 1420,
    strictPort: true,
    watch: {
      ignored: ['**/src-tauri/**']
    }
  },
  envPrefix: ['VITE_', 'TAURI_'],
  resolve: {
    alias: {
      '@': frontendDir,
      '~': path.resolve(rootDir, 'src')
    }
  },
  build: {
    target: ['es2022', 'chrome110', 'safari15'],
    outDir: 'dist',
    emptyOutDir: true
  }
});
