import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      '@kit': resolve(__dirname, 'vendor/gnexus-ui-kit'),
      'gnexus-ui-kit/vue': resolve(__dirname, 'vendor/gnexus-ui-kit/dist/vue/index.js'),
      'gnexus-ui-kit/css': resolve(__dirname, 'vendor/gnexus-ui-kit/dist/css/kit.css')
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        loadPaths: [
          resolve(__dirname, 'vendor/gnexus-ui-kit/src/scss')
        ]
      }
    }
  },
  build: {
    outDir: resolve(__dirname, 'dist'),
    emptyOutDir: true
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:8000',
        rewrite: path => path.replace(/^\/api/, '')
      },
      '/ws': {
        target: 'ws://localhost:8000',
        ws: true
      }
    }
  }
})
