-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbabel.config.cjs
More file actions
43 lines (38 loc) · 991 Bytes
/
Copy pathbabel.config.cjs
File metadata and controls
43 lines (38 loc) · 991 Bytes
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
try {
require("dotenv").config();
} catch {
// dotenv is optional for consumers that embed the SDK without the demo workspace.
}
const ARGUS_DEMO_ENV_KEYS = [
"ARGUS_DEMO_BACKEND_URL",
"EXPO_PUBLIC_ARGUS_DEMO_BACKEND_URL",
"ARGUS_DEMO_PARTNER_ID",
"ARGUS_DEMO_USE_CASE",
];
function argusDemoEnvPlugin({ types: t }) {
function envObjectExpression() {
return t.objectExpression(
ARGUS_DEMO_ENV_KEYS.map((key) =>
t.objectProperty(
t.identifier(key),
process.env[key] ? t.stringLiteral(process.env[key]) : t.identifier("undefined"),
),
),
);
}
return {
name: "argus-demo-env",
visitor: {
Identifier(path) {
if (path.node.name !== "__ARGUS_DEMO_ENV__" || !path.isReferencedIdentifier()) {
return;
}
path.replaceWith(envObjectExpression());
},
},
};
}
module.exports = {
presets: ["module:@react-native/babel-preset"],
plugins: [argusDemoEnvPlugin],
};