/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('@react-native/metro-config').MetroConfig}
 */
const { getDefaultConfig } = require('@expo/metro-config')

const os = require('os');
if (!os.availableParallelism) {
  os.availableParallelism = () => Math.max(os.cpus().length - 1, 1);
}


/** @type {import('expo/metro-config').MetroConfig} */
let config = getDefaultConfig(__dirname, {
  // [Web-only]: Enables CSS support in Metro.
  isCSSEnabled: false,
})

// 2. Enable Tamagui
const { withTamagui } = require('@tamagui/metro-plugin')
const tamaguiConfig = withTamagui(config)

// Tamagui's plugin strips scss/sass from sourceExts — restore them so
// expo-doctor's Metro config check passes.
const defaults = getDefaultConfig(__dirname)
tamaguiConfig.resolver.sourceExts = [
  ...new Set([...tamaguiConfig.resolver.sourceExts, ...defaults.resolver.sourceExts]),
]

module.exports = tamaguiConfig

