/** * EVM Adapter: Vite Configuration Export * * This module exports Vite configuration fragments for the EVM adapter. * Currently minimal, but provides a consistent interface for adapter-specific * build requirements. * * USAGE: * 1. In the main builder app: Import and merge into packages/builder/vite.config.ts * 2. In exported apps: The export system injects these configs when EVM is used * * See: docs/ADAPTER_ARCHITECTURE.md ยง "Build-Time Requirements" */ import type { UserConfig } from 'vite'; /** * Returns the Vite configuration required for EVM adapter compatibility * * @returns Vite configuration object to be merged with your main vite.config * * @example * ```typescript * // vite.config.ts * import { getEvmViteConfig } from '@openzeppelin/adapter-evm/vite-config'; * * export default defineConfig(({ mode }) => { * const evmConfig = getEvmViteConfig(); * * return { * plugins: [ * react(), * ...evmConfig.plugins, * ], * resolve: { * dedupe: [ * ...evmConfig.resolve.dedupe, * ], * }, * }; * }); * ``` */ export function getEvmViteConfig(): UserConfig { return { // Currently no EVM-specific plugins required plugins: [], resolve: { // Module Deduplication // Ensure singleton instances of shared dependencies dedupe: [ // EVM-specific dependencies that may need deduplication 'viem', 'wagmi', '@wagmi/core', ], }, optimizeDeps: { // Force pre-bundling of runtime wallet dependencies that are loaded lazily // through wagmi/RainbowKit so dev mode gets stable ESM interop. include: [ 'wagmi', '@wagmi/core', '@wagmi/connectors', 'viem', '@tanstack/react-query', '@rainbow-me/rainbowkit', '@metamask/sdk', 'debug', 'events', ], exclude: [], }, }; }