axeldelafosse / expo-next-monorepo-example

Create a universal React app using Expo and Next.js in a monorepo

Home Page:https://expo-next-monorepo-example.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better app.config.ts

hirbod opened this issue · comments

Hi @axeldelafosse,

before I went ahead to create a PR, I would like to know if we're on the same page.
Since this package is using app.config.js, we don't have the magic Intellisense automatically using a VSCode plugin. But what can be done is:

  • Rename app.config.js to app.config.ts
  • Update package.json inside packages/expo and change main from index.js to index.ts
  • Rename packages/expo/index.js to index.ts

Change contents like so:

import { ExpoConfig } from '@expo/config-types';

declare var process: {
  env: {
    STAGE: "development" | "staging" | "production",
    SCHEME: string,
  }
}

const STAGE = process.env.STAGE;
const SCHEME = process.env.SCHEME ?? 'aaa.bbb.ccc';

const envConfig = {
  development: {
    scheme: `${SCHEME}.development`,
    icon: './assets/icon.development.png',
    backgroundColor: '#FF0000'
  },
  staging: {
    scheme: `${SCHEME}.staging`,
    icon: './assets/icon.staging.png',
    backgroundColor: '#8000FF'
  },
  production: {
    scheme: SCHEME,
    icon: './assets/icon.png',
    backgroundColor: '#1610FF'
  }
};

const stageConfig = envConfig[STAGE ?? 'development'];

const config: ExpoConfig = {
.....
  • Named export
  • A bit more semantic
  • And IntelliSense powered by Expo Config-Types

What do you think?

Yeah that's a good idea! Thank you very much!

Alright, some more insights. You can't rename index.js to index.ts, but thats ok.
Expo prebuild will fail in that case.

Everything else remains valid.

Sounds good. Feel free to send a PR, I'll review and merge ASAP.

This repo is now deprecated in favour of Solito