Re.Pack uses the same configuration system as Rspack and webpack. This means you can leverage the extensive configuration options from either of the bundlers while working with React Native projects. Re.Pack comes with minimal, development & production-ready defaults that work out of the box, but as your project grows, you may need to customize various aspects of the bundling process.
Since Re.Pack is built on top of Rspack and webpack, you can refer to their respective documentation for available configuration options:
For example, if you want to configure output options for your bundles, you would look up these options in the Rspack output documentation or webpack output documentation and use them in the project config:
You can find all available options in the respective bundler's documentation. Most configuration options work the same way as they do in Rspack/webpack, with some React Native specific extensions that we'll cover later in this guide.
Re.Pack ships with template configurations to help you get started. These templates provide sensible defaults and common configurations for both Rspack and webpack.
Configuration can be defined in two ways: as a static object or as a function that returns a configuration object.
The simplest form is a static object that defines your configuration:
For more flexibility, you can export a function that returns the configuration object. This is useful when you need to:
ios
or android
)mode
The env
argument is an object with the following properties:
Property | Type | Description |
---|---|---|
mode | string | Compilation mode ('production' or 'development' ) |
platform | string | Target application platform |
context | string | Context in which all resolution happens (usually project root directory) |
entry | string | Input filename - entry point of the bundle |
bundleFilename | string | Bundle output filename - name under which generated bundle will be saved |
sourceMapFilename | string | Source map filename for the main bundle |
assetsPath | string | Directory where generated static assets will be saved |
minimize | boolean | Whether to minimize the final bundle |
reactNativePath | string | Path to React Native dependency (usually points to node_modules/react-native ) |
devServer | object | undefined | Development server configuration options |
Re.Pack follows a specific order when resolving configuration values. When the same option is defined in multiple places, the value with higher precedence takes priority. Here's the precedence order from highest to lowest:
--mode production
)rspack.config.js
or webpack.config.js
)For example, if you set the mode
in your configuration file:
But run the CLI with a different mode:
The CLI flag (production
) will take precedence over the configuration file value (development
).
Below you can find the defaults for each command.
Remember that if you define the same options in your configuration file (e.g. rspack.config.cjs
or webpack.config.cjs
), they will take effect over the defaults listed below.
start
commandbundle
commandThese are the base defaults that Re.Pack provides regardless of the command being run:
Re.Pack extends the configuration system with few features to make things easier. These values will be resolved before passing the configuration to the bundler and starting the compilation.
The output.path
option supports the [platform]
placeholder which gets replaced with the current platform value:
The devServer.host
option supports special values:
Value | Resolves to |
---|---|
"local-ip" | "localhost" |
"local-ipv4" | "127.0.0.1" |
"local-ipv6" | "::1" |
The resolve.extensions
option supports the [platform]
placeholder to enable platform-specific file resolution. This allows you to use platform-specific files like MyComponent.ios.js
or MyComponent.android.js
: