import { defineConfig } from 'astro/config'
import tailwind from '@astrojs/tailwind'
import react from '@astrojs/react'

import node from '@astrojs/node'

import sitemap from '@astrojs/sitemap';

import robotsTxt from 'astro-robots-txt';

import { attachPaymentMonitorWs } from './server/paymentMonitorWs.mjs'

// En dev el WebSocket del monitor se monta sobre el servidor de Vite; en produccion lo hace server.mjs.
const paymentMonitorWsDev = () => ({
  name: 'previcar-payment-monitor-ws',
  configureServer (server) {
    if (server.httpServer) attachPaymentMonitorWs(server.httpServer)
  }
})

// https://astro.build/config
export default defineConfig({
  site: 'https://previcar.com.co',
  integrations: [tailwind(), react(), sitemap({ filter: (page) => !page.includes('/interno/') }), robotsTxt()],
  adapter: node({
    mode: 'standalone'
  }),
  vite: {
    plugins: [paymentMonitorWsDev()]
  }
})
