react-native-dotenv
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -35,3 +35,3 @@ const {readFileSync} = require('fs') | ||
const babelMode = process.env.APP_ENV || process.env.BABEL_ENV || process.env.NODE_ENV || 'development' | ||
const babelMode = process.env.APP_ENV || (process.env.BABEL_ENV && process.env.BABEL_ENV !== 'undefined' && process.env.BABEL_ENV) || process.env.NODE_ENV || 'development' | ||
if (this.opts.safe) { | ||
@@ -38,0 +38,0 @@ const parsed = parseDotenvFile(this.opts.path, this.opts.verbose) |
{ | ||
"name": "react-native-dotenv", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "Load environment variables using import statements.", | ||
@@ -5,0 +5,0 @@ "repository": "github:goatandsheep/react-native-dotenv", |
@@ -168,5 +168,25 @@ # react-native-dotenv [![CircleCI](https://circleci.com/gh/goatandsheep/react-native-dotenv.svg?style=svg)](https://circleci.com/gh/goatandsheep/react-native-dotenv) | ||
## TypeScript | ||
### Reference Material | ||
- Create a `types` folder in your project | ||
- Inside that folder, create a `*.d.ts`file, say, `env.d.ts` | ||
- in that file, declare a module as the following format: | ||
```ts | ||
declare module '@env' { | ||
export const API_BASE: string; | ||
} | ||
``` | ||
Add all of your .env variables inside this module. | ||
- Finally, add this folder into the `typeRoots` field in your `tsconfig.json` file: | ||
```json | ||
{ | ||
... | ||
"typeRoots": ["./src/types"], | ||
... | ||
} | ||
``` | ||
## Reference Material | ||
* [babel environments](https://babeljs.io/docs/en/6.26.3/babelrc#env-option) | ||
@@ -187,2 +207,16 @@ * [dotenv documentation](https://www.npmjs.com/package/dotenv) | ||
or | ||
`yarn start --reset-cache` | ||
or | ||
`expo r -c` | ||
Maybe a solution for updating package.json scripts: | ||
> "cc": "rimraf node_modules/.cache/babel-loader/*,", | ||
> "android": "npm run cc && react-native run-android", | ||
> "ios": "npm run cc && react-native run-ios", | ||
Or you can override the default `cacheIdentifier` to include some of your environment variables. | ||
@@ -189,0 +223,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27211
242
14