Skip to main content

Dot Env File

The .env file in Mongez has all CRA features with more additional features.

The current schema for .env file looks like:

GENERATE_SOURCEMAP=false
REACT_APP_KEY_NAME="mongez"REACT_APP_NAME="Application Name"REACT_APP_DESCRIPTION="Application Description"
REACT_APP_COLOR=#3ab792
REACT_APP_LOCALE_CODES_LIST=en,ar,frREACT_APP_DIRECTION=ltrREACT_APP_LOCALE_CODE=en
REACT_APP_API_BASE_URL=https://api.sitename.comREACT_APP_API_KEY=xxxx
PUBLIC_URL=https://sitename.comREACT_APP_PRODUCTION_BASE_PATH=/

Let's have a deeper look at it.

  • GENERATE_SOURCEMAP: will disable generated sitemap on building the application for production, this will decrease build time and size.
  • REACT_APP_KEY_NAME: Application unique name, useful for some modules like Encryption.
  • REACT_APP_NAME: Application Title, will be set in public/index.htmlin the title tag and will be set in the production build.
  • REACT_APP_DESCRIPTION: Application Description, will be set in public/index.htmlin the meta description tag and will be set in the production build.
  • REACT_APP_COLOR: Applicaion bar color in the mobile browser, used in theme-color meta tag, also its recommended to set the application primary color in this key.
  • REACT_APP_LOCALE_CODES_LIST: List of all available locale codes in the application, separated by comma.
  • REACT_APP_DIRECTION: Default application direction, can be ltr or rtl, also is set in the dir attribute in the html tag.
  • REACT_APP_LOCALE_CODE: Default application locale code, also is set in the lang attribute in the html tag.
  • REACT_APP_API_BASE_URL: Api Base url, should be used in the src/shared/config.ts file under the endpoint.baseUrl.
  • REACT_APP_API_BASE_URL: Api api key, should be used in the src/shared/config.ts file under the endpoint.apiKey if the application has api key.
  • PUBLIC_URL: The url for Production build, it should be fully written, domain/sub-domain with sub directory if it iwll be in a folder not in the root.
  • REACT_APP_KEY_NAME: If the production url will be in the root i.e in domain.com or sub.domain.com, then leave it to be /, if the project will be in a sub directory i.e domain.com/my-app then the value should be /my-app.