Options
All
  • Public
  • Public/Protected
  • All
Menu

@xarc/app

Index

Type Aliases

XarcCdnAssetsMappingOptions: { extendRequire?: any; mapping?: Record<string, unknown>; prodOnly?: boolean }

Options for setting up CDN assets mapping

Type declaration

  • Optional extendRequire?: any

    isomorphic-loader extend require instance

    • if not provided, then the default instance is used
  • Optional mapping?: Record<string, unknown>

    assets mapping data

    • if not provided, then will try to load it from one of these files:
    1. dist/cdn-mappings.json
    2. config/assets.json
  • Optional prodOnly?: boolean

    Only setup in production mode (NODE_ENV === "production")

Properties

isomorphicLoader: any

Variables

ETMP_DIR: ".etmp" = ".etmp"
PROD_DIR: ".prod" = ".prod"
xAppRequire: NodeRequire = require

This is the require from @xarc/app's directory.

Functions

  • loadRuntimeSupport(options?: XarcSupportOptions): Promise<any>
  • start node.js run time support for app server

    Parameters

    • options: XarcSupportOptions = {}

      options on what runtime support to start

    Returns Promise<any>

    Promise

  • makeAppMode(prodDir?: string, reactLib?: string): any
  • Figure out the mode app is setup.

    1. src/client, src/server => lib
    2. src/{subapp-directories}, src/server => lib
    3. which react lib is being used (default react)

    And then setup the env APP_SRC_DIR so in dev mode code in src is executed with run time compiler like @babel/register, but in prod mode transpiled code in lib will be executed.

    Parameters

    • prodDir: string = PROD_DIR

      directory to save data of the app mode

    • reactLib: string = "react"

      UI framework (react)

    Returns any

    app mode data

  • setupAppSrcDir(): void
  • Setup APP_SRC_DIR when running node.js server

    • src/ in development mode
    • lib/ in production mode

    Returns void

    nothing

  • setupIsomorphicLoader(ignoreExtensions?: string | false | string[]): any
  • Load the require hook to support isomorphic assets when doing SSR

    Parameters

    • ignoreExtensions: string | false | string[] = ".css|.scss|.sass|.pcss|.stylus|.styl|.less|.sss|.gif|.jpeg|.jpg|.png|.svg|.mp4|.webm|.ogv|.aac|.mp3|.wav|.ogg"

      when a require file is not found, and its extension is in this, then it will be considered an isomorphic asset and an empty {} will be returned for it to avoid failing with module not found errors.

      • Default ".css|.scss|.sass|.pcss|.stylus|.styl|.less|.sss|.gif|.jpeg|.jpg|.png|.svg|.mp4|.webm|.ogv|.aac|.mp3|.wav|.ogg"
      • set to false to disable this and let module not found error to throw

    Returns any

    isomorphic require extender

Generated using TypeDoc