Custom Metro Configuration
WaveMaker React Native apps are bundled with Metro using a default configuration. You can add your own Metro settings on top of it, for example to support extra asset types or to tune the build.
When to use it
Use a custom Metro configuration for any Metro setting that WaveMaker's defaults don't cover, for example:
- Extra asset types: bundle files such as animations, 3D models, ML models or prepopulated databases by adding their extensions to
resolver.assetExts. - Module resolution: add aliases with
resolver.extraNodeModules, or exclude folders withresolver.blockList. - Build performance: set
maxWorkersfor build machines with limited memory, or configure Metro's cache withcacheStoresandcacheVersion. - Metro plugins from libraries: some libraries ship a function that wraps the Metro configuration. For example, Sentry's
withSentryConfigadds source map support for error reporting.
Adding a custom Metro configuration
- In Studio, create a file named
custommetro.config.jsin thesrc/main/webappfolder of your project. - Export an async function from this file. The function receives WaveMaker's Metro
configobject, already set up with WaveMaker's defaults. Change only what you need and return it. - Build the app. WaveMaker copies the file into the generated app and applies your function after its own settings.
If the file isn't present, the app builds with WaveMaker's default Metro configuration.
Example
The following configuration adds lottie as an asset extension, adds a module alias, gives Metro its own cache folder and limits it to four workers:
Always return the config object from the function.
Example: Sentry
Libraries that provide a Metro plugin take a configuration and return a wrapped one. Pass WaveMaker's config to the plugin and return the result:
The library must be available in the project. To add an npm package, see Third-party expo plugins