save 4min

Member-only story

One line of code increased the React Native CI/CD build speed by 22%

Davyd NRB
1 min readJan 20, 2023

Every release build of React Native uses terser to reduce the size of your JavaScript. And this operation can be omitted for Staging/Beta builds.

Add an if statement using the env variable in the android/app/build.gradle file:

project.ext.react = [
enableHermes: true,
extraPackagerArgs: System.getenv("NO_MINIFY_JS") ? ["--minify", "false", "--reset-cache", "false"]: []
]

Open Xcode for iOS, choose "Build Phases" => "Bundle React Native code and images" and add the following code at the beginning:

export EXTRA_PACKAGER_ARGS=""
# ^^^ Can be added you default args (for example '--sourcemap-output')

if [ "$NO_MINIFY_JS" == "1" ]; then
export EXTRA_PACKAGER_ARGS="$EXTRA_PACKAGER_ARGS --minify false --reset-cache false"
fi
# ...

Add NO_MINIFY_JS=1 environment variable, to CI for Non-Production builds after that.

The results are depicted in the screenshot up top (minus 4 minutes).

In the comments area, feel free to ask any questions you may have.

MurAmur ©

--

--

Davyd NRB
Davyd NRB

Written by Davyd NRB

React Native guru 🧘\ DevOps adjutant \ Linux lover ❤️

Responses (1)

Write a response