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

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      '@components': path.resolve(__dirname, 'src/components'),
      '@views': path.resolve(__dirname, 'src/views'),
      '@assets': path.resolve(__dirname, 'src/assets'),
      '@utils': path.resolve(__dirname, 'src/utils'),
      '@api': path.resolve(__dirname, 'src/api'),
      '@stores': path.resolve(__dirname, 'src/stores')
    }
  },
  server: {
    port: process.env.VITE_PORT || 3003,
    host: process.env.VITE_HOST || '::', // 明确支持IPv4和IPv6
    open: false,
    allowedHosts: ['localhost', '127.0.0.1'],
    // 支持IPv6访问
    strictPort: false,
    cors: true
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@use "@/assets/styles/variables.scss" as vars;'
      }
    }
  }
})