Skip to content

Commit 03c8cda

Browse files
committed
docs: update
1 parent 2d453ae commit 03c8cda

3 files changed

Lines changed: 81 additions & 0 deletions

File tree

docs/docs/docs/api-reference/configuration.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ Example:
5858
"expo": {
5959
"packageName": "com.example.app",
6060
"minSdkVersion": 24,
61+
"extraProguardRules": [
62+
"-keep class com.example.Foo { *; }"
63+
],
64+
"minifyEnabled": false,
6165
"useLocalGradlePlugin": true
6266
}
6367
},
@@ -187,6 +191,8 @@ All file-based platform options mirror CLI flags, but they use camelCase propert
187191
| `android.expo.artifactId` | `string` | Maven artifact ID used when publishing the AAR. |
188192
| `android.expo.version` | `string` | Maven version used when publishing the AAR. |
189193
| `android.expo.useLocalGradlePlugin` | `boolean` | Load the Brownfield Gradle plugin from `node_modules` via `includeBuild` instead of the Maven classpath dependency. Disabled by default. |
194+
| `android.expo.minifyEnabled` | `boolean` | Controls `minifyEnabled` for the generated Android library build. Disabled by default. |
195+
| `android.expo.extraProguardRules` | `string[]`| Additional Proguard rules appended to the generated `proguard-rules.pro`. |
190196

191197
### iOS keys
192198

docs/docs/docs/guides/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
"guidelines",
3+
"minification",
34
"troubleshooting",
45
{
56
"type": "dir",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Minification
2+
3+
This guide shows how to enable minification for both Expo and bare React Native brownfield modules.
4+
5+
## Expo
6+
7+
Configure minification through the Brownfield config in `package.json` and let `expo prebuild` apply it to the generated module.
8+
9+
Steps:
10+
11+
1. Add a `brownfield` block to `package.json` and enable `android.expo.minifyEnabled`.
12+
2. Add keep rules in `android.expo.extraProguardRules` for generated Brownie store types, navigation types, and host manager classes you need to keep.
13+
3. Run `expo prebuild` to regenerate the Android module with the new settings.
14+
15+
Example (see `apps/ExpoApp56`):
16+
17+
```json
18+
{
19+
"brownfield": {
20+
"debug": true,
21+
"android": {
22+
"expo": {
23+
"minifyEnabled": true,
24+
"extraProguardRules": [
25+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.BrownfieldStore { *; }",
26+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.BrownfieldStore$Companion { *; }",
27+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.User { *; }",
28+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.SettingsStore { *; }",
29+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.SettingsStore$Companion { *; }",
30+
"-keep class com.callstack.rnbrownfield.demo.expoapp56.Theme { *; }",
31+
"-keep class com.callstack.nativebrownfieldnavigation.UserType { *; }"
32+
]
33+
}
34+
}
35+
}
36+
}
37+
```
38+
39+
## Bare React Native
40+
41+
For bare React Native, you do not need any Brownfield config. Enable minification in the module itself and add Proguard rules manually.
42+
43+
Steps:
44+
45+
1. In your `brownfieldlib/build.gradle.kts`, enable `isMinifyEnabled = true` in the `release` build type.
46+
2. Ensure `proguard-rules.pro` keeps the generated Brownie store types, navigation types, and your host manager if you have one.
47+
48+
Example (see `apps/RNApp`):
49+
50+
```kts
51+
android {
52+
buildTypes {
53+
release {
54+
isMinifyEnabled = true
55+
proguardFiles(
56+
getDefaultProguardFile("proguard-android-optimize.txt"),
57+
"proguard-rules.pro"
58+
)
59+
}
60+
}
61+
}
62+
```
63+
64+
```
65+
-keep class com.rnapp.brownfieldlib.BrownfieldStore { *; }
66+
-keep class com.rnapp.brownfieldlib.BrownfieldStore$Companion { *; }
67+
-keep class com.rnapp.brownfieldlib.User { *; }
68+
-keep class com.rnapp.brownfieldlib.SettingsStore { *; }
69+
-keep class com.rnapp.brownfieldlib.SettingsStore$Companion { *; }
70+
-keep class com.rnapp.brownfieldlib.Theme { *; }
71+
-keep class com.rnapp.brownfieldlib.ReactNativeHostManager { *; }
72+
73+
-keep class com.callstack.nativebrownfieldnavigation.UserType { *; }
74+
```

0 commit comments

Comments
 (0)