-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathapp.config.js
42 lines (34 loc) · 1.31 KB
/
app.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
const assert = require('assert');
const { version: expoVersion } = require('expo/package.json');
const { string } = require('getenv');
const { major } = require('semver');
/**
* @param {object} params
* @param {import('expo/config').ExpoConfig} params.config
* @returns {import('expo/config').ExpoConfig}
*/
module.exports = ({ config }) => {
// Set web export prefix major Expo SDK version.
// This is used to properly host the web build on Snack's S3 hosting.
config.experiments ||= {};
config.experiments.baseUrl = `/v2/${major(expoVersion)}`;
const projectId = string('EXPO_PROJECT_ID', null);
// Dynamically configure the EAS project ID, if not configured yet.
if (!config.extra?.eas?.projectId) {
assert(projectId, 'Environment variable "EXPO_PROJECT_ID" is required');
config.extra ||= {};
config.extra.eas ||= {};
config.extra.eas.projectId = projectId;
}
// Dynamically configure the EAS endpoint, if not configured yet.
if (!config.updates?.url) {
assert(projectId, 'Environment variable "EXPO_PROJECT_ID" is required');
config.updates ||= {};
if (string('EXPO_PUBLIC_SNACK_ENV') === 'staging') {
config.updates.url = `https://staging-u.expo.dev/${projectId}`;
} else {
config.updates.url = `https://u.expo.dev/${projectId}`;
}
}
return config;
};