import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

export default defineConfig({
  base: './',
  server: {
    hmr: true,
    port: 8080,
    open: true,
    host: true
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  plugins: [
    vue(),
    VueSetupExtend(),
    AutoImport({
      imports: ['vue', 'vue-router', 'pinia'],
      dts: 'src/auto-import.d.ts', // 生成 `auto-import.d.ts` 全局声明
      eslintrc: {
        enabled: true,
        filepath: './.eslintrc.js'
      },
      dirs: ['src/utils'],
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  // build: {
  //   minify: 'terser',
  //   terserOptions: {
  //     compress: {
  //       //生产环境时移除console
  //       drop_console: true,
  //       drop_debugger: true
  //     }
  //   }
  // },
  optimizeDeps: {
    include: ['schart.js']
  }
})
