Global "magic" variables

Global "magic" variables

We define a few useful globally available variables:

  • DEV — true when webpack is building in development mode

    if (__DEV__) {
      // we are running a dev build
    }
  • global.isAndroid, ANDROID — true when the platform is Android

    if (global.isAndroid) {
      // we are running on android
    }
  • global.isIOS, IOS — true when the platform is iOS

    if (global.isIOS) {
      // we are running on iOS
    }
The following variables are also defined but are primarily intended to be used by NativeScript Core internally, or plugins that wish to use these.
  • NS_WEBPACK — always true when building with webpack

  • NS_ENV_VERBOSEtrue when --env.verbose is set

  • NS_DEV_HOST_IPS — an array of IP addresses of the host machine (the machine running the build) when in development mode, and an empty array in production mode.

  • CSS_PARSER — the css parser used by NativeScript Core. The value is set based on the cssParser value in the nativescript.config.ts and defaults to css-tree

  • UI_USE_XML_PARSER — a flag used by NativeScript Core to disable the XML parser when it’s not used

  • UI_USE_EXTERNAL_RENDERER — a flag used by NativeScript Core to disable registering global modules when an external renderer is used.