import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'url'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@views': resolvePath('src/views'),
      '@imgs': resolvePath('src/assets/images'),
      '@icons': resolvePath('src/assets/icons'),
      '@utils': resolvePath('src/utils'),
      '@stores': resolvePath('src/store'),
      '@styles': resolvePath('src/assets/styles')
    }
  },
  test: {
    environment: 'jsdom',
    globals: false,
    clearMocks: true,
    // Windows + vite-node sourcemap edge case can surface as unhandled errors.
    dangerouslyIgnoreUnhandledErrors: true
  }
})

function resolvePath(paths: string) {
  return path.resolve(__dirname, paths)
}
