What is @expo/metro-config?
@expo/metro-config is a configuration package for Metro, the JavaScript bundler used by React Native. It provides a set of default configurations optimized for Expo projects, making it easier to set up and customize the Metro bundler for your React Native applications.
What are @expo/metro-config's main functionalities?
Default Configuration
This feature provides a default configuration for Metro bundler, optimized for Expo projects. It simplifies the setup process by providing sensible defaults.
const { getDefaultConfig } = require('@expo/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
module.exports = defaultConfig;
Custom Configuration
This feature allows you to customize the default Metro configuration. For example, you can add custom file extensions to the resolver.
const { getDefaultConfig } = require('@expo/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.sourceExts.push('cjs');
module.exports = defaultConfig;
Asset Plugins
This feature allows you to add custom asset plugins to the Metro configuration. For example, you can add a plugin to hash asset files.
const { getDefaultConfig } = require('@expo/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.transformer.assetPlugins = ['expo-asset/tools/hashAssetFiles'];
module.exports = defaultConfig;
Other packages similar to @expo/metro-config
metro-config
metro-config is the official configuration package for Metro bundler. It provides a flexible way to customize the Metro bundler for React Native projects. Unlike @expo/metro-config, it does not come with Expo-specific defaults.
haul
haul is an alternative JavaScript bundler for React Native that offers more customization options compared to Metro. It can be used as a replacement for Metro and provides its own set of configuration options, making it more flexible but also more complex to set up.