import { v4wp } from "@kucrut/vite-for-wp";
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
import react from "@vitejs/plugin-react";
import path from "path"

export default defineConfig({
  plugins: [
    v4wp({
      input: "resources/src/admin/main.jsx",
      outDir: "assets/admin/dist",
    }),
    // wp_scripts(),
    tailwindcss(),
    react(),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./resources/src/admin"),
    },
  },
  server: {
    port: 5174,
    origin: 'http://localhost:5174', // optional, default
    // cors: {
    //   origin: '*', // or: ['http://your-wp.test']
    //   methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
    //   allowedHeaders: ['Content-Type', 'Authorization']
    // },
    cors: true,
    hmr: {
      protocol: 'ws',
      host: 'localhost'
    }
  }
});