import { defineConfig } from 'vite';
import adonisjs from '@adonisjs/vite/client';
// import { getDirname } from '@adonisjs/core/helpers';
import vue from '@vitejs/plugin-vue';
import path from 'path';
// import tailwind from '@tailwindcss/postcss';
// import autoprefixer from 'autoprefixer';
// import postcssNesting from 'postcss-nesting';
import inertia from '@adonisjs/inertia/client';

export default defineConfig({
    plugins: [
        inertia(),
        vue(),
        adonisjs({
            /**
             * Entrypoints of your application. Each entrypoint will
             * result in a separate bundle.
             */
            entrypoints: ['resources/js/app.ts', 'resources/css/app.css'],

            /**
             * Paths to watch and reload the browser on file change
             */
            reload: ['resources/views/**/*.edge'],
        }),
    ],
    server: { 
        port: 5173,     
        // host: '127.0.0.1'  
      }, 

    // css: {
    //     postcss: {
    //         plugins: [
    //             postcssNesting(),
    //             tailwind(),
    //             autoprefixer(),
    //         ],
    //     },
    // },
    /**
     * Define aliases for importing modules from
     * your frontend code
     */
    resolve: {
        alias: {
            '@': path.resolve('./resources/js/'),
            '~': path.resolve(__dirname, 'node_modules/'),
        },
    },

    // optimizeDeps: {
    //     esbuildOptions: {
    //         target: 'esnext'
    //       },
    //     include: ['resources/js/**/*.{vue,js,jsx,ts,tsx}'],
    //     exclude: ['node_modules', 'app'],
    // },

    build: {
        sourcemap: true, 
        outDir: 'public/assets',
        emptyOutDir: true,
        manifest: true,
        rollupOptions: {
            input: 'resources/js/app.ts',
        },
    },
    // build: {
    //     outDir: 'public/assets',
    //     emptyOutDir: true,
    //     manifest: true,
    //     rollupOptions: {
    //       input: path.resolve(__dirname, 'resources/js/app.ts'),
    //     },
    //   },
});
