import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import symfonyPlugin from 'vite-plugin-symfony';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';

const __dirname = dirname(fileURLToPath(import.meta.url));

export default defineConfig({
  plugins: [
    react(),
    symfonyPlugin({ refresh: true }),
  ],
  resolve: {
    alias: {
      '@mine-components': resolve(__dirname, './assets/js/mine-seeker/components'),
      '@mine-contexts': resolve(__dirname, './assets/js/mine-seeker/contexts'),
      '@mine-hooks': resolve(__dirname, './assets/js/mine-seeker/hooks'),
      '@mine-utils': resolve(__dirname, './assets/js/mine-seeker/utils'),
      '@global-utils': resolve(__dirname, './assets/js/utils'),
      '@global-components': resolve(__dirname, './assets/js/components'),
    },
  },
  build: {
    rollupOptions: {
      input: {
        mineseeker: './assets/js/app.jsx',
        passkey: './assets/js/passkey.jsx',
        profile: './assets/js/profile.jsx',
        contact: './assets/js/contact.jsx',
        mineseekerStyle: './assets/css/style.mineseeker.scss',
        homeStyle: './assets/css/style.layout.scss',
        passkeyStyle: './assets/css/passkey.scss',
      },
    },
  },
  server: {
    cors: {
      origin: ['https://mine.local', 'http://mine.local'],
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern',
        silenceDeprecations: ['import'],
      },
    },
  },
});
