import path from "path";

import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";

// https://vite.dev/config/
export default defineConfig({
	base: "/",
	plugins: [react(), tailwindcss(), svgr()],
	server: {
		host: "127.0.0.1",
		allowedHosts: true,
		port: 3000,
		proxy: {
			"/api": {
				target: "http://127.0.0.1:5000",
				changeOrigin: true,
				secure: false,
			},
			"/hubs": {
				target: "http://127.0.0.1:5100",
				changeOrigin: true,
				ws: true,
				secure: false,
			},
		},
	},
	resolve: {
		alias: {
			"@": path.resolve(__dirname, "src"),
		},
	},
	css: {
		preprocessorOptions: {
			less: {
				javascriptEnabled: true,
			},
		},
		postcss: { plugins: [] },
	},
});
