import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import svgLoader from 'vite-svg-loader'
import { fileURLToPath, URL } from 'node:url'
import viteIconNames from './scripts/vite-icon-names.js'

export default defineConfig({
  plugins: [vue(), svgLoader(), viteIconNames()],
  envPrefix: 'VITE',
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern-compiler',
      },
    },
  },
  resolve: {
    extensions: ['.mjs', '.js', '.json', '.vue'],
    alias: {
      '@': fileURLToPath(new URL('src', import.meta.url)),
    },
    mainFields: ['browser', 'module', 'main', 'jsnext:main', 'jsnext'],
  },
})
