const { getDefaultConfig } = require('expo/metro-config');
const { getSentryExpoConfig } = require('@sentry/react-native/metro');

module.exports = (() => {
  const baseConfig = getDefaultConfig(__dirname);

  const config = getSentryExpoConfig(__dirname, baseConfig);

  config.transformer = {
    ...config.transformer,
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
    minifierConfig: {
      keep_fnames: true,
      mangle: {
        keep_fnames: true
      }
    },
    _expoRelativeProjectRoot: __dirname,
  };

  config.resolver = {
    ...config.resolver,
    assetExts: config.resolver.assetExts.filter((ext) => ext !== 'svg').concat(['db']),
    sourceExts: [...config.resolver.sourceExts, 'svg']
  };

  return config;
})();
