import {defineConfig} from "vite";
import tailwindcss from "@tailwindcss/vite";
import vue from "@vitejs/plugin-vue";
import {fileURLToPath, URL} from 'node:url';

export default defineConfig({
    plugins: [
        tailwindcss(),
        vue({
            template: {
                compilerOptions: {
                    isCustomElement: tag => tag.startsWith('swiper-'),
                },
            },
        }),
    ],

    base: '/image/catalog/tgshopspa/',
    build: {
        outDir: '../../module/oc_telegram_shop/upload/image/catalog/tgshopspa',
        emptyOutDir: true,
        sourcemap: false,
        manifest: true,
        minify: 'terser',
        reportCompressedSize: true,
        terserOptions: {
            compress: {
                drop_console: true,
                drop_debugger: true,
            },
        },
    },

    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
        },
    },

    server: {
        host: true,
        allowedHosts: ["tg.nikitakiselev.ru"],
        proxy: {
            '/index.php': {
                target: 'http://localhost:8000',
                changeOrigin: true,
                rewrite: path => path,
            }
        }
    },
});
