Search code examples
react-nativereact-native-web

Expo web development ENV build


What is the best way to build an Expo web app development build?

  1. Does expo build:web -d build a web app with __DEV__ set to true within the built/deployed app?

I have tried this method but I am still seeing DEV as false.

If this is the expected behavior, what does the -d flag do when building expo for web?

  1. Using dotenv, how can I create development vs. production builds using expo build:web? https://github.com/goatandsheep/react-native-dotenv

  2. How can app.json / app.config.js extra fields be used to set up staging env? https://docs.expo.dev/versions/latest/config/app/#extra Is use of __DEV__ necessary?


Solution

  • Implemented a development staging build by following comments here by passing a BUILD_STAGING key when executing the build script and checking for the key value in app.config.js:

    github.com/expo/expo-cli/issues/948

    // app.config.js
    export default {
      expo: {
        apiUrl: process.env.STAGING_BUILD === 'development' ? 'DEV_API_URL' : 'API_URL',
      },
    };
    
    
    // build script
    BUILD_STAGING=development expo build:web