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

export default defineConfig({
  plugins: [vue()],
  resolve: {
    // 避免删除 src 内过期 .js 后仍优先请求 index.js 导致 404
    extensions: ['.ts', '.tsx', '.mjs', '.js', '.mts', '.jsx', '.json', '.vue'],
    alias: {
      // shared 的 dist 为 CommonJS，Vite 无法按命名导出加载；直连源码
      '@thebet365/shared': resolve(__dirname, '../../packages/shared/src/index.ts'),
    },
  },
  publicDir: resolve(__dirname, '../../packages/shared/public'),
  server: {
    port: 5173,
    proxy: {
      '/api': { target: 'http://localhost:3000', changeOrigin: true },
      '/uploads': { target: 'http://localhost:3000', changeOrigin: true },
    },
  },
});
