import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { LayuiVueResolver } from 'unplugin-vue-components/resolvers'
import VueDevTools from 'vite-plugin-vue-devtools'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VueDevTools(),
    AutoImport({
      resolvers: [LayuiVueResolver()],
      imports: [
        'vue',
        'pinia',
        'vue-router'
      ],
      dirs: [
        './src/utils'
      ],
      eslintrc: {
        enabled: true
      },
      vueTemplate: true
    }),
    Components({
      resolvers: [LayuiVueResolver()]
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  css: {
    preprocessorOptions: {
      scss: { charset: false },
      less: {
        javascriptEnabled: true
      }
    }
  },
  server: {
    port: 3000,
    cors: true,
    proxy: {}
  },
  envDir: path.resolve(__dirname, 'env')
})
