import path from "path"
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import monacoEditorPlugin from './vite.monaco-editor';

export default defineConfig({
  define: {
    global: {},
  },
  plugins: [react(),monacoEditorPlugin()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server: {
    proxy: {
      '/mgmt': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      },
      '/api': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      },
      '/actionLogin.do': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      },
      '/actionLogout.do': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      },
      '/img': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      },
      '/servers': {
        target: 'http://localhost:38080',
        changeOrigin: true,
        secure: false,
      }
    }
  },
  optimizeDeps: {
    include: ['@monaco-editor/react'],
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          // Split Monaco Editor into a separate chunk
          'monaco-editor': ['monaco-editor'],
        },
      },
    },
  },
})
