The AssetsLoader
processes image and other static assets (video, audio, etc.) in your React Native application. It handles asset extraction, copying files to the appropriate platform-specific output directories, and supports additional features like base64 inlining and conversion into remote assets.
By default, extracted asset files are copied to assets/
directory for iOS and drawable-*
directories (e.g. drawable-mdpi
, drawable-hdpi
, etc.) for Android which matches Metro's asset handling behavior.
Looking to do more with your assets? Check out the guides on:
string
compiler.options.name
Target platform (e.g. ios
or android
). The default value is the name of the compiler which Re.Pack sets to the target platform.
string[]
SCALABLE_ASSETS
Array of file extensions that support scaling suffixes (@1x
, @2x
etc).
See SCALABLE_ASSETS for a list of extensions supported by default.
string[]
SCALABLE_RESOLUTIONS
Array of supported resolution scales.
See SCALABLE_RESOLUTIONS for a list of resolutions supported by default.
boolean
undefined
Whether development server is enabled. By default, this option is determined by checking if compiler.options.devServer
is defined.
boolean
false
When true, assets will be inlined as base64 in the JS bundle instead of being extracted to separate files.
string
undefined
Public path for local asset URLs.
object
Configuration for remote asset handling.
boolean
true
When true, assets will be converted to remote assets meant to be served from a CDN or external server.
string
true
Base URL where remote assets will be hosted. Must start with http://
or https://
.
(args: AssetPathArgs) => string
undefined
Custom function to control how remote asset paths are constructed. Applied to both generated folder paths and URLs.
You can exclude specific asset types from being processed by the AssetsLoader
. This is useful when you want to use a different loader for certain file types (e.g. .svg
files)
Here's how to exclude .svg
files and process them with a custom loader instead: