forked from zoontek/react-native-bootsplash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native.config.js
74 lines (68 loc) · 2.09 KB
/
react-native.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const path = require("path");
const { generate } = require("./dist/commonjs/generate");
module.exports = {
commands: [
{
name: "generate-bootsplash <logoPath>",
description: "Generate a launch screen using an original logo file",
options: [
{
name: "--background-color <color>",
description:
"color used as launch screen background (in hexadecimal format)",
default: "#fff",
},
{
name: "--logo-width <width>",
description:
"logo width at @1x (in dp - we recommend approximately ~100)",
default: 100,
parse: (value) => parseInt(value, 10),
},
{
name: "--assets-path [path]",
description:
"path to your static assets directory (useful to require the logo file in JS)",
},
{
name: "--flavor <flavor>",
description:
'[android only] flavor build variant (outputs in an android resource directory other than "main")',
default: "main",
},
],
func: (
[logoPath],
{ project: { android, ios } },
{ backgroundColor, logoWidth, assetsPath, flavor },
) => {
const workingPath =
process.env.INIT_CWD || process.env.PWD || process.cwd();
if (logoWidth > 288) {
console.log(
"❌ Logo width can't be superior to 288dp as it will be cropped on Android. Exiting…\n",
);
process.exit(1);
} else if (logoWidth > 192) {
console.log(
"⚠️ As logo width is superior to 192dp, it might be cropped on Android.\n",
);
}
return generate({
android,
ios,
workingPath,
logoPath: path.resolve(workingPath, logoPath),
assetsPath: assetsPath
? path.resolve(workingPath, assetsPath)
: undefined,
backgroundColor,
flavor,
logoWidth,
}).catch((error) => {
console.error(error);
});
},
},
],
};