import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    enforce: "default",
    plugins: [
        laravel({
            input: [
                'resources/sass/app.scss',
                'resources/sass/admin.scss',
                'resources/js/app.js'
            ],
            refresh: true
        })
    ],
    build: {
        sourcemap: false,
        emptyOutDir: true,
        rollupOptions: {
            output: {
                entryFileNames(chunk) {
                    if (/mobile/.test(chunk.name)) {
                        return 'mobile/[name].js'
                    }
                    return '[name].js';
                },
                chunkFileNames(chunk) {
                    if (/mobile/.test(chunk.name)) {
                        return 'mobile/[name].js'
                    }
                    return '[name].js';
                },
                assetFileNames(chunk) {
                    if (/mobile/.test(chunk.name)) {
                        return 'mobile/[name].[ext]'
                    }
                    return '[name].[ext]';
                },
                // entryFileNames: '[name].js',
                // chunkFileNames: '[name].js',
                // assetFileNames: '[name].[ext]'
            }
        },
        commonjsOptions: {
            include: [/node_modules/]
        }
    },
    resolve: {
        alias: {
            '@': '/resources/js'
        },
    }
});
