One of Re.Pack key design goals was to give as much power and control to the developer — to you. This means that Re.Pack doesn't hide anything under its own proprietary configuration, but uses regular Webpack configuration.
By default, when running
react-native webpack-start or
react-native webpack-bundle, Re.Pack will look for Webpack configuration in the following places:
<root> is your project's root directory.
The paths above are the same ones that normal Webpack CLI looks for Webpack configuration.
Notice that you can use
.js extension for Webpack config file. When looking for configuration file, Re.Pack will first try
.cjs and finally
.js extensions. We recommend to use
.cjs to be explicit.
If you want to store Webpack config in different place, you can provide custom path:
react-native webpack-start --webpackConfig <path>
react-native webpack-bundle --webpackConfig <path>
webpack-cli -c <path>
<path> starts with
../, it will be treated as relative path - it will be resolved based on root directory detected by React Native CLI, which usually points to your project's root directory.
Webpack config template
Every project is different, has different structure, uses different dependencies, has different requirements, so we cannot know what Webpack configuration your project might needs. Instead we give use a sensible and well-documented Webpack config template to use as a base and adjust some bits based on your project.
Please, refer to this document for templates.
We highly encourage to create recipes for adding or adjusting the support for other common use cases not included in the default template. We welcome any PR!
Re.Pack's config APIs
To make Webpack-produced bundle compatible and runnable by React Native, Re.Pack gives you a set of Webpack plugins.
By default, all boring plugin configuration is abstracted behind a single
RepackPlugin, which should suffice to most projects.
However, in cause you need more control over the Re.Pack plugins, you can remove
RepackPlugin and use plugins from
- AssetsResolverPlugin (required)
- DevelopmentPlugin (required only in development)
- RepackTargetPlugin (required)
- OutputPlugin (required)
Not including required plugins will break your build or cause your app to crash at runtime!
Additionally, Re.Pack gives you few helper functions:
It entirely possible not to use the functions above, but it's highly recommended to use them.