import { resolve } from 'path';
import handlebars from 'vite-plugin-handlebars';

export default {
  esbuild: {
    supported: {
      'top-level-await': true, //browsers can handle top-level-await features
    },
  },
  base: './',
  plugins: [
    handlebars({
      partialDirectory: resolve(__dirname, 'src', 'partials'),
    }),
  ],
  build: {
    minify: false,
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'src', 'pages', 'index.html'),
        materials: resolve(__dirname, 'src', 'pages', 'materials.html'),
        materialsSingle: resolve(
          __dirname,
          'src',
          'pages',
          'materials-single.html'
        ),
        events: resolve(__dirname, 'src', 'pages', 'events.html'),
        eventSingle: resolve(__dirname, 'src', 'pages', 'event-single.html'),
        notFound: resolve(__dirname, 'src', 'pages', '404.html'),
        advertiser: resolve(__dirname, 'src', 'pages', 'advertiser.html'),
        subscription: resolve(__dirname, 'src', 'pages', 'subscription.html'),
        interviews: resolve(__dirname, 'src', 'pages', 'interviews.html'),
        about: resolve(__dirname, 'src', 'pages', 'about.html'),
        partners: resolve(__dirname, 'src', 'pages', 'partners.html'),
        pages: resolve(__dirname, 'src', 'pages', 'pages.html'),
        contacts: resolve(__dirname, 'src', 'pages', 'contacts.html'),
        partnersSingle: resolve(
          __dirname,
          'src',
          'pages',
          'partners-single.html'
        ),
        search: resolve(__dirname, 'src', 'pages', 'search.html'),
      },
      output: {
        entryFileNames: `assets/[name].js`,
        chunkFileNames: `assets/[name].js`,
        assetFileNames: `assets/[name].[ext]`,
      },
    },
  },
  server: {
    open: '/src/pages/pages.html',
    hmr: {
      // Включаем горячую перезагрузку (HMR) для CSS
      overlay: true,
    },
  },

};
