Skip to content

Commit 5123553

Browse files
nazmelnNazarii Melnyk
and
Nazarii Melnyk
authored
feat: Adds conditional assets generations (zoontek#441)
* feat: add conditional assets generations * fix comments --------- Co-authored-by: Nazarii Melnyk <nazarii.melnyk@kilo.health>
1 parent 22c7731 commit 5123553

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Options:
128128
--logo-width <width> logo width at @1x (in dp - we recommend approximately ~100) (default: 100)
129129
--assets-path [path] path to your static assets directory (useful to require the logo file in JS)
130130
--flavor <flavor> [android only] flavor build variant (outputs in an android resource directory other than "main")
131+
--platforms [platforms] platforms to generate assets for (comma separated) (default: "android,ios")
131132
-h, --help output usage information
132133
```
133134

@@ -138,7 +139,8 @@ yarn react-native generate-bootsplash assets/bootsplash_logo_original.png \
138139
--background-color=F5FCFF \
139140
--logo-width=100 \
140141
--assets-path=assets \
141-
--flavor=main
142+
--flavor=main \
143+
--platforms=android,ios
142144
```
143145

144146
![](https://raw.githubusercontent.com/zoontek/react-native-bootsplash/master/docs/cli_tool.png?raw=true)

react-native.config.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,28 @@ module.exports = {
3232
'[android only] flavor build variant (outputs in an android resource directory other than "main")',
3333
default: "main",
3434
},
35+
{
36+
name: '--platforms [platforms]',
37+
description: 'platforms to generate the splash screen for (android, ios)',
38+
default: 'android,ios',
39+
parse: (value) => value.split(','),
40+
}
3541
],
3642
func: (
3743
[logoPath],
3844
{ project: { android, ios } },
39-
{ backgroundColor, logoWidth, assetsPath, flavor },
45+
{ backgroundColor, logoWidth, assetsPath, flavor, platforms },
4046
) => {
4147
const workingPath =
4248
process.env.INIT_CWD || process.env.PWD || process.cwd();
4349

50+
const iosOnly = platforms.includes('ios');
51+
const androidOnly = platforms.includes('android');
52+
4453
return generate({
45-
android,
54+
android: android && androidOnly ? android : null,
4655

47-
ios: ios
56+
ios: ios && iosOnly
4857
? {
4958
...ios,
5059
// Fix to support previous CLI versions

0 commit comments

Comments
 (0)