diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..e57b309 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +TEST_KEY='help' \ No newline at end of file diff --git a/App.js b/App.js index d177db3..3e828c9 100644 --- a/App.js +++ b/App.js @@ -12,7 +12,6 @@ const App = () => { const [loading, setLoading] = useState(true) const [location, setLocation] = useState(null) const [error, setError] = useState(null) - useEffect(() => { ;(async () => { let { status } = await Location.requestForegroundPermissionsAsync() @@ -25,6 +24,8 @@ const App = () => { })() }, []) + console.log(process.env.TEST_KEY) + if (location) { console.log(location) } diff --git a/babel.config.js b/babel.config.js index 2900afe..e3507b3 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,6 +1,28 @@ -module.exports = function(api) { - api.cache(true); +module.exports = function (api) { + api.cache(true) return { presets: ['babel-preset-expo'], - }; -}; + env: { + production: { + plugins: [ + [ + 'inline-dotenv', + { + path: '.env.production' + } + ] + ] + }, + development: { + plugins: [ + [ + 'inline-dotenv', + { + path: '.env.development' + } + ] + ] + } + } + } +} diff --git a/package-lock.json b/package-lock.json index ab2814b..78ef692 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,10 +21,12 @@ "devDependencies": { "@babel/core": "^7.20.0", "@react-native-community/eslint-config": "^3.2.0", + "babel-plugin-inline-dotenv": "^1.7.0", "eslint": "^8.43.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-react": "^7.32.2", - "prettier": "2.8.8" + "prettier": "2.8.8", + "react-native-dotenv": "^3.4.9" } }, "node_modules/@ampproject/remapping": { @@ -6063,6 +6065,23 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/babel-plugin-inline-dotenv": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/babel-plugin-inline-dotenv/-/babel-plugin-inline-dotenv-1.7.0.tgz", + "integrity": "sha512-FUrXEwY9R9ZO8l0NFHqXFBzHjjMvdIJlELrzJoE6imDsj6Vh7g9svm7iHPHVYPbHmt6BPB2eCAJkwvG6kr5byg==", + "dev": true, + "dependencies": { + "dotenv": "^16.0.0" + }, + "peerDependencies": { + "dotenv-expand": ">= 5.0.0" + }, + "peerDependenciesMeta": { + "dotenv-expand": { + "optional": true + } + } + }, "node_modules/babel-plugin-module-resolver": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-4.1.0.tgz", @@ -7376,6 +7395,18 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -13670,6 +13701,18 @@ "nullthrows": "^1.1.1" } }, + "node_modules/react-native-dotenv": { + "version": "3.4.9", + "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.9.tgz", + "integrity": "sha512-dbyd+mcy7SUzxEgmt33TRf1FGcNe6swJhXmB0unKkI49F7+pidog9kPtjxMLTAfmKA8gcN2XHQSKltGfGbGCLQ==", + "dev": true, + "dependencies": { + "dotenv": "^16.3.1" + }, + "peerDependencies": { + "@babel/runtime": "^7.20.6" + } + }, "node_modules/react-native-gradle-plugin": { "version": "0.71.19", "resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.19.tgz", diff --git a/package.json b/package.json index eb06b27..e9cf280 100644 --- a/package.json +++ b/package.json @@ -13,20 +13,22 @@ "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/native": "^6.1.6", "expo": "~48.0.18", + "expo-location": "~15.1.1", "expo-status-bar": "~1.4.4", "react": "18.2.0", "react-native": "0.71.8", "react-native-safe-area-context": "4.5.0", - "react-native-screens": "~3.20.0", - "expo-location": "~15.1.1" + "react-native-screens": "~3.20.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@react-native-community/eslint-config": "^3.2.0", + "babel-plugin-inline-dotenv": "^1.7.0", "eslint": "^8.43.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-react": "^7.32.2", - "prettier": "2.8.8" + "prettier": "2.8.8", + "react-native-dotenv": "^3.4.9" }, "private": true }