import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import eslintPlugin from 'vite-plugin-eslint';
import fs from 'fs';

// https://vitejs.dev/config/
export default defineConfig({
  base: '/callapp/',
  plugins: [
    react(),
    // 配置eslint检查的目录
    eslintPlugin({
      include: ['src/**/*.js', 'src/**/*.jsx'],
    }),
  ],
  resolve: {
    alias: {
      '@components': path.resolve(__dirname, './src/components'),
      '@pages': path.resolve(__dirname, './src/pages'),
      '@assets': path.resolve(__dirname, './src/assets'),
      '@api': path.resolve(__dirname, './src/api'),
      '@utils': path.resolve(__dirname, './src/utils'),
    },
  },
  server: {
    host: '0.0.0.0',
    hmr: true, // 关闭热更新 http://m00.puruiit.cn:3596
    proxy: {
      // https://np.h03.p0551.com http://10.1.2.29:8090
      '/bdhealth/': { 
        target: 'http://m00.puruiit.cn:3596/bdhealth/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/bdhealth\//, ''),
      },
    },
  },
});
