/** * Vite config for WordPress plugin build. * Builds the full CP app and outputs to integrations/wordpress/dist/. * * Usage: pnpm build:wp * * (c) 2026 TWWIM UG. All rights reserved. (www.twwim.com) */ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { TanStackRouterVite } from '@tanstack/router-plugin/vite'; import tailwindcss from '@tailwindcss/vite'; import path from 'path'; // Swap index.css → index.wp.css at import resolution time function wpCssSwap() { const from = path.resolve(__dirname, 'src/index.css'); const to = path.resolve(__dirname, 'src/index.wp.css'); return { name: 'wp-css-swap', enforce: 'pre' as const, resolveId(source: string, importer: string | undefined) { if (!importer) return; const resolved = path.resolve(path.dirname(importer), source); if (resolved === from) { return to; } }, }; } export default defineConfig({ plugins: [ wpCssSwap(), TanStackRouterVite(), react(), tailwindcss(), ], resolve: { alias: { '@': path.resolve(__dirname, './src'), '@domain': path.resolve(__dirname, './src/domain'), '@application': path.resolve(__dirname, './src/application'), '@infrastructure': path.resolve(__dirname, './src/infrastructure'), '@presentation': path.resolve(__dirname, './src/presentation'), }, }, base: './', build: { // Output dir is env-driven so the e2e variant emits to // `integrations/wordpress/plugin/dist.e2e/` without clobbering the regular // `dist/` produced by `pnpm build:wp`. outDir: path.resolve( __dirname, `../../integrations/wordpress/plugin/${process.env.WP_DIST_DIR || 'dist'}`, ), emptyOutDir: true, }, });