// Metro config für Expo + pnpm Monorepo
// Quelle: https://docs.expo.dev/guides/monorepos/

const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');
const path = require('path');

const projectRoot = __dirname;
const monorepoRoot = path.resolve(projectRoot, '../..');

const config = getDefaultConfig(projectRoot);

// 1. Watch alle Workspace-Pakete
config.watchFolders = [monorepoRoot];

// 2. Auflösung über Workspace-root + lokale node_modules
config.resolver.nodeModulesPaths = [
  path.resolve(projectRoot, 'node_modules'),
  path.resolve(monorepoRoot, 'node_modules'),
];

// 3. Symlinks via pnpm
config.resolver.unstable_enableSymlinks = true;
config.resolver.unstable_enablePackageExports = true;

// 4. .riv (Rive-Animation) als Asset registrieren
config.resolver.assetExts = [...(config.resolver.assetExts ?? []), 'riv'];

module.exports = withNativeWind(config, {
  input: './global.css',
});
