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

const projectRoot = process.env.PROJECT_ROOT || process.cwd()
const sdkRoot = process.cwd()

console.log('📂 SDK Root:', sdkRoot)
console.log('📂 Project Root:', projectRoot)

export default defineConfig({
  plugins: [react()],
  server: {
    port: 3000,
    open: true
  },
  resolve: {
    alias: {
      '@project': resolve(projectRoot, 'src')
    }
  },
  optimizeDeps: {
    include: ['react', 'react-dom', 'react-dom/client']
  },
  build: {
    commonjsOptions: {
      include: [/react-dom/, /react/]
    }
  }
})