I got an application what we white-label for others. This means we share the same functionality through the apps but there are some specific design elements (mostly colors and pictures) in each app.
I'm looking for the easiest and best way to identify the built app for my Expo React Native codebase.
My plan is store everything in the same javascript codebase, and just get load the correct config files by the application name.
In this case, I would get a few apps in the stores:
All of them would load the same expo app: exp.host/@comp/colours
And this expo app should set the background to blue in the BlueApp and red in the RedApp.
! I don't want to detach my expo app, I want to still build my apps with the expo.
It is possible to use a different configuration file by doing expo start --config=some-app.json
. One problem I ran into is that some assets were still being required at a specific location (eg. assets/images/icon.png).
The solution I came up with is to switch the project, via a bash script, every time you start a project. That way, the development you run you will also publish without fussing around config parameters that expo may or may not support.
So in your package.json you can have run commands which look like this:
./switch project1 && expo start
The bash script would sync all assets from src directory, including app.json to their expected paths. The directory structure would looks like this:
src
- project1
- app.json
- assets
- project2
- app.json
- assets
and the script:
#!/bin/bash
if [ $1 == "swaggr" ] || [ $1 == "chatsera" ]
then
echo "switching to $1"
unlink app.json
cp ./src/$1/app.json ./app.json
rsync -rvz ./src/$1/assets/ ./assets/
else
echo "could not switch project. $1 is invalid"
fi
If you use this approach I'd probably add app.json and all assets in .gitignore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With