import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import autoprefixer from 'autoprefixer';

export default defineConfig({
    define: {
        'process.env': {}
    },
    plugins: [
        laravel({
            input: [
                'resources/assets/vue/app.ts',
                'resources/assets/js/vendor.js',
                'resources/assets/css/vendor.css',
                'resources/assets/js/site.js',
                'resources/assets/css/site.css',
            ],
            refresh: true,
        }),
        vue(),
        viteStaticCopy({
            targets: [
                // Vendor flags
                {
                    src: 'node_modules/flag-icon-css/flags/**/*',
                    dest: 'flag-icon-css/flags'
                },
                // Vendor fonts
                {
                    src: 'node_modules/font-awesome/fonts/**/*',
                    dest: 'fonts'
                },
                // Source images
                {
                    src: 'resources/assets/images/**/*',
                    dest: '../images'
                },
                // Source fonts
                {
                    src: 'resources/assets/fonts/**/*',
                    dest: 'fonts'
                },
            ]
        }),
    ],
    resolve: {
        alias: {
            '@': resolve(__dirname, './resources/assets/vue'),
            'vue': 'vue/dist/vue.esm-bundler.js',
        },
    },
    server: {
        host: '0.0.0.0',
        port: 5173,
        hmr: {
            host: 'localhost',
        },
    },
});
