import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

const reactPkg = path.resolve(__dirname, '../../../frontends/mizan-react/src')

export default defineConfig({
    plugins: [react()],
    resolve: {
        alias: {
            'mizan/channels': path.join(reactPkg, 'channels/index.ts'),
            'mizan/client/react': path.join(reactPkg, 'client/react.ts'),
            'mizan/client': path.join(reactPkg, 'client/index.ts'),
            'mizan/jwt': path.join(reactPkg, 'jwt/index.ts'),
            'mizan': path.join(reactPkg, 'index.ts'),
            '@rythazhur/mizan/channels': path.join(reactPkg, 'channels/index.ts'),
            '@rythazhur/mizan/jwt': path.join(reactPkg, 'jwt/index.ts'),
            '@rythazhur/mizan': path.join(reactPkg, 'index.ts'),
        },
    },
    server: {
        proxy: {
            '/api': 'http://localhost:8000',
            '/ws': { target: 'ws://localhost:8000', ws: true },
        },
    },
})
