import { resolve } from "node:path";
import { lingui } from "@lingui/vite-plugin";
import react from "@vitejs/plugin-react";
import postcss from "postcss";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";

export default defineConfig({
	plugins: [
		react({
			babel: {
				plugins: ["macros"],
			},
		}),
		postcss(),
		lingui(),
		dts(),
	],
	build: {
		lib: {
			entry: [
				resolve(__dirname, "index.ts"),
				resolve(__dirname, "/styles/index.css"),
				resolve(__dirname, "/styles/default-fonts.css"),
			],
			name: "@socket.tech/bungee",
			formats: ["es"],
			fileName: "index",
		},
		rollupOptions: {
			external: ["react", "react-dom", "wagmi", "viem", "@tanstack/react-query"],
		},
		cssCodeSplit: true,
		cssMinify: true,
		sourcemap: true,
	},
	resolve: {
		alias: {
			"@components": resolve(__dirname, "src/components"),
			"@components/common": resolve(__dirname, "src/components/common"),
			"@hooks": resolve(__dirname, "src/hooks"),
			"@utils": resolve(__dirname, "src/utils"),
			"@store": resolve(__dirname, "src/store"),
			"@providers": resolve(__dirname, "src/Providers"),
			"@assets": resolve(__dirname, "./assets"),
		},
	},
});
