import { wayfinder } from '@laravel/vite-plugin-wayfinder';
import tailwindcss from '@tailwindcss/vite';
import vue from '@vitejs/plugin-vue';
import laravel from 'laravel-vite-plugin';
import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/js/app.ts',
                'resources/admin/css/styles.css',
            ],
            ssr: 'resources/js/ssr.ts',
            refresh: true,
        }),
        tailwindcss(),
        wayfinder({
            formVariants: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    server: {
        host: '0.0.0.0',
        port: 5173,
        strictPort: true,
        hmr: {
            host: 'cartxis.test',
        },
        cors: {
            origin: ['https://cartxis.test', 'http://cartxis.test'],
            credentials: true,
        },
    },
    resolve: {
        alias: [
            { find: /^@\/Layouts/, replacement: '/resources/js/layouts' },
            { find: '@admin', replacement: '/resources/admin' },
            { find: '@themes', replacement: '/themes' },
            { find: '@', replacement: '/resources/js' },
        ],
    },
});
