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

// 统一使用 path.resolve
const resolve = (dir) => path.resolve(__dirname, dir)

export default defineConfig({
  base: process.env.ELECTRON ? './' : '/',
  plugins: [vue()],
  server: {
    host: '0.0.0.0',  // 允许通过IP访问
    port: 3000,       // 设置端口号
    open: true        // 自动打开浏览器
  },
  resolve: {
    alias: {
      '@': resolve('src'),
      '@views': resolve('src/views'),
      '@components': resolve('src/components'),
      '@assets': resolve('src/assets'),
    }
  },
  assetsInclude: ['**/*.JPG'], // 添加对 .JPG 文件的支持
  build: {
    chunkSizeWarningLimit: 1500,
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return 'vendor';
          }
        }
      }
    }
  }
})